Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/lobby/lobby.js
Show All 23 Lines | |||||
const g_LobbyServer = Engine.ConfigDB_GetValue("user", "lobby.server"); | const g_LobbyServer = Engine.ConfigDB_GetValue("user", "lobby.server"); | ||||
/** | /** | ||||
* Current games will be listed in these colors. | * Current games will be listed in these colors. | ||||
*/ | */ | ||||
var g_GameColors = { | var g_GameColors = { | ||||
"init": "0 219 0", | "init": "0 219 0", | ||||
"waiting": "255 127 0", | "waiting": "255 127 0", | ||||
"running": "219 0 0" | "running": "219 0 0" | ||||
ffffffff: remove empty attributes or set them default color | |||||
}; | }; | ||||
Done Inline ActionsCan be moved to default.cfg too if the other ones are there too I suppose elexis: Can be moved to default.cfg too if the other ones are there too I suppose | |||||
/** | /** | ||||
* Initial sorting order of the gamelist. | * Initial sorting order of the gamelist. | ||||
*/ | */ | ||||
var g_GameStatusOrder = ["init", "waiting", "running"]; | var g_GameStatusOrder = ["init", "waiting", "running"]; | ||||
/** | /** | ||||
* The playerlist will be assembled using these values. | * The playerlist will be assembled using these values. | ||||
▲ Show 20 Lines • Show All 356 Lines • ▼ Show 20 Lines | function init(attribs) | ||||
updateToggleBuddy(); | updateToggleBuddy(); | ||||
Engine.GetGUIObjectByName("chatInput").tooltip = colorizeAutocompleteHotkey(); | Engine.GetGUIObjectByName("chatInput").tooltip = colorizeAutocompleteHotkey(); | ||||
// Get all messages since the login | // Get all messages since the login | ||||
for (let msg of Engine.LobbyGuiPollHistoricMessages()) | for (let msg of Engine.LobbyGuiPollHistoricMessages()) | ||||
g_NetMessageTypes[msg.type][msg.level](msg); | g_NetMessageTypes[msg.type][msg.level](msg); | ||||
} | } | ||||
function updateLobbyColumns() | function updateLobbyColumns() | ||||
Not Done Inline Actionssome valdidate color test ffffffff: some valdidate color test | |||||
{ | { | ||||
let gameRating = Engine.ConfigDB_GetValue("user", "lobby.columns.gamerating") == "true"; | let gameRating = Engine.ConfigDB_GetValue("user", "lobby.columns.gamerating") == "true"; | ||||
Not Done Inline Actionsthis is sadfuly not working fall apart anyway ffffffff: this is sadfuly not working fall apart anyway | |||||
Done Inline Actionsduplication / hardcoding. Use for i in g_GameColors... elexis: duplication / hardcoding. Use for i in g_GameColors... | |||||
// Only show the selected columns | // Only show the selected columns | ||||
let gamesBox = Engine.GetGUIObjectByName("gamesBox"); | let gamesBox = Engine.GetGUIObjectByName("gamesBox"); | ||||
gamesBox.hidden_mapType = gameRating; | gamesBox.hidden_mapType = gameRating; | ||||
Done Inline Actionssame elexis: same | |||||
gamesBox.hidden_gameRating = !gameRating; | gamesBox.hidden_gameRating = !gameRating; | ||||
// Only show the filters of selected columns | // Only show the filters of selected columns | ||||
let mapTypeFilter = Engine.GetGUIObjectByName("mapTypeFilter"); | let mapTypeFilter = Engine.GetGUIObjectByName("mapTypeFilter"); | ||||
mapTypeFilter.hidden = gameRating; | mapTypeFilter.hidden = gameRating; | ||||
let gameRatingFilter = Engine.GetGUIObjectByName("gameRatingFilter"); | let gameRatingFilter = Engine.GetGUIObjectByName("gameRatingFilter"); | ||||
gameRatingFilter.hidden = !gameRating; | gameRatingFilter.hidden = !gameRating; | ||||
▲ Show 20 Lines • Show All 176 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
/** | /** | ||||
* 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 sortBy = playersBox.selected_column || "name"; | let sortBy = playersBox.selected_column || "buddy"; | ||||
Done Inline ActionsI believe the default value must be deleted as it is a relic from buggycode times. elexis: I believe the default value must be deleted as it is a relic from buggycode times.
XML should… | |||||
let sortOrder = playersBox.selected_column_order || 1; | let sortOrder = playersBox.selected_column_order || 1; | ||||
let buddyStatusList = []; | let buddyStatusList = []; | ||||
let playerList = []; | let playerList = []; | ||||
let presenceList = []; | let presenceList = []; | ||||
let nickList = []; | let nickList = []; | ||||
let ratingList = []; | let ratingList = []; | ||||
let cleanPlayerList = Engine.GetPlayerList().map(player => { | let cleanPlayerList = Engine.GetPlayerList().map(player => { | ||||
player.isBuddy = g_Buddies.indexOf(player.name) != -1; | player.isBuddy = g_Buddies.indexOf(player.name) != -1; | ||||
return player; | return player; | ||||
}).sort((a, b) => { | }).sort((a, b) => { | ||||
let sortA, sortB; | let sortA, sortB; | ||||
let statusOrder = Object.keys(g_PlayerStatuses); | let statusOrder = Object.keys(g_PlayerStatuses); | ||||
let statusA = statusOrder.indexOf(a.presence) + a.name.toLowerCase(); | let statusA = statusOrder.indexOf(a.presence) + a.name.toLowerCase(); | ||||
let statusB = statusOrder.indexOf(b.presence) + b.name.toLowerCase(); | let statusB = statusOrder.indexOf(b.presence) + b.name.toLowerCase(); | ||||
Not Done Inline ActionsCan't we do the buddy test here? elexis: Can't we do the buddy test here? | |||||
Not Done Inline Actionswhat do you mean with buddy test? L737? why not there? ffffffff: what do you mean with buddy test? L737? why not there? | |||||
Not Done Inline ActionsI think I misread the patch, nevermind unless I recall what I meant eventually. elexis: I think I misread the patch, nevermind unless I recall what I meant eventually. | |||||
Not Done Inline Actionsnp ffffffff: np
further comments? | |||||
switch (sortBy) | switch (sortBy) | ||||
{ | { | ||||
case 'buddy': | case 'buddy': | ||||
sortA = (a.isBuddy ? 1 : 2) + statusA; | sortA = (a.name == g_Username ? 0 : a.isBuddy ? 1 : 2) + statusA; | ||||
sortB = (b.isBuddy ? 1 : 2) + statusB; | sortB = (b.name == g_Username ? 0 : b.isBuddy ? 1 : 2) + statusB; | ||||
break; | break; | ||||
case 'rating': | case 'rating': | ||||
sortA = +a.rating; | sortA = +a.rating; | ||||
sortB = +b.rating; | sortB = +b.rating; | ||||
break; | break; | ||||
case 'status': | case 'status': | ||||
sortA = statusA; | sortA = statusOrder.indexOf(a.presence); | ||||
sortB = statusB; | sortB = statusOrder.indexOf(b.presence); | ||||
// if presences equal user priored first/last | |||||
if (sortA == sortB) | |||||
{ | |||||
if (a.name == g_Username) return -sortOrder; | |||||
if (b.name == g_Username) return +sortOrder; | |||||
} | |||||
sortA += b.name.toLowerCase(); | |||||
sortB += a.name.toLowerCase(); | |||||
break; | break; | ||||
case 'name': | case 'name': | ||||
default: | default: | ||||
sortA = a.name.toLowerCase(); | sortA = a.name.toLowerCase(); | ||||
sortB = b.name.toLowerCase(); | sortB = b.name.toLowerCase(); | ||||
break; | break; | ||||
} | } | ||||
if (sortA < sortB) return -sortOrder; | if (sortA < sortB) return -sortOrder; | ||||
if (sortA > sortB) return +sortOrder; | if (sortA > sortB) return +sortOrder; | ||||
return 0; | return 0; | ||||
}); | }); | ||||
// Colorize list entries | // Colorize list entries | ||||
for (let player of cleanPlayerList) | for (let player of cleanPlayerList) | ||||
{ | { | ||||
if (player.rating && player.name == g_Username) | if (player.rating && player.name == g_Username) | ||||
g_UserRating = player.rating; | g_UserRating = player.rating; | ||||
let rating = player.rating ? (" " + player.rating).substr(-5) : " -"; | let rating = player.rating ? (" " + player.rating).substr(-5) : " -"; | ||||
let presence = g_PlayerStatuses[player.presence] ? player.presence : "unknown"; | let presence = g_PlayerStatuses[player.presence] ? player.presence : "unknown"; | ||||
if (presence == "unknown") | if (presence == "unknown") | ||||
warn("Unknown presence:" + player.presence); | warn("Unknown presence:" + player.presence); | ||||
let statusColor = g_PlayerStatuses[presence].color; | let statusColor = player.name == g_Username ? g_UserColor : g_PlayerStatuses[presence].color; | ||||
buddyStatusList.push(player.isBuddy ? coloredText(g_BuddySymbol, statusColor) : ""); | let buddySymbol = player.name == g_Username ? g_UserSymbol : player.isBuddy ? g_BuddySymbol : ""; | ||||
buddyStatusList.push(coloredText(buddySymbol, statusColor)); | |||||
playerList.push(colorPlayerName((player.role == "moderator" ? g_ModeratorPrefix : "") + player.name)); | playerList.push(colorPlayerName((player.role == "moderator" ? g_ModeratorPrefix : "") + player.name)); | ||||
presenceList.push(coloredText(g_PlayerStatuses[presence].status, statusColor)); | presenceList.push(coloredText(g_PlayerStatuses[presence].status, statusColor)); | ||||
Done Inline ActionsDon't colorize the empty string elexis: Don't colorize the empty string | |||||
ratingList.push(coloredText(rating, statusColor)); | ratingList.push(coloredText(rating, statusColor)); | ||||
nickList.push(player.name); | nickList.push(player.name); | ||||
} | } | ||||
playersBox.list_buddy = buddyStatusList; | playersBox.list_buddy = buddyStatusList; | ||||
playersBox.list_name = playerList; | playersBox.list_name = playerList; | ||||
playersBox.list_status = presenceList; | playersBox.list_status = presenceList; | ||||
playersBox.list_rating = ratingList; | playersBox.list_rating = ratingList; | ||||
▲ Show 20 Lines • Show All 245 Lines • ▼ Show 20 Lines | for (let player of stringifiedTeamListToPlayerData(game.players)) | ||||
let [nick, rating] = splitRatingFromNick(player.Name); | let [nick, rating] = splitRatingFromNick(player.Name); | ||||
if (player.Team != "observer") | if (player.Team != "observer") | ||||
playerRatings.push(rating || g_DefaultLobbyRating); | playerRatings.push(rating || g_DefaultLobbyRating); | ||||
// Sort games with playing buddies above games with spectating buddies | // Sort games with playing buddies above games with spectating buddies | ||||
if (game.hasBuddies < 2 && g_Buddies.indexOf(nick) != -1) | if (game.hasBuddies < 2 && g_Buddies.indexOf(nick) != -1) | ||||
game.hasBuddies = player.Team == "observer" ? 1 : 2; | game.hasBuddies = player.Team == "observer" ? 1 : 2; | ||||
game.hasUser = game.hasUser || player.Name == g_Username; | |||||
} | } | ||||
game.gameRating = | game.gameRating = | ||||
playerRatings.length ? | playerRatings.length ? | ||||
Math.round(playerRatings.reduce((sum, current) => sum + current) / playerRatings.length) : | Math.round(playerRatings.reduce((sum, current) => sum + current) / playerRatings.length) : | ||||
g_DefaultLobbyRating; | g_DefaultLobbyRating; | ||||
return game; | return game; | ||||
}).filter(game => !filterGame(game)).sort((a, b) => { | }).filter(game => !filterGame(game)).sort((a, b) => { | ||||
// keep user games priored first/last | |||||
if (a.hasUser) return -sortOrder; | |||||
if (b.hasUser) return +sortOrder; | |||||
Done Inline ActionsI didn't know we had a way to tag players as users. elexis: I didn't know we had a way to tag players as users. | |||||
let sortA, sortB; | let sortA, sortB; | ||||
switch (sortBy) | switch (sortBy) | ||||
{ | { | ||||
case 'name': | case 'name': | ||||
sortA = g_GameStatusOrder.indexOf(a.state) + a.name.toLowerCase(); | sortA = g_GameStatusOrder.indexOf(a.state) + a.name.toLowerCase(); | ||||
sortB = g_GameStatusOrder.indexOf(b.state) + b.name.toLowerCase(); | sortB = g_GameStatusOrder.indexOf(b.state) + b.name.toLowerCase(); | ||||
break; | break; | ||||
case 'gameRating': | case 'gameRating': | ||||
Show All 35 Lines | function updateGameList() | ||||
{ | { | ||||
let game = g_GameList[i]; | let game = g_GameList[i]; | ||||
let gameName = escapeText(game.name); | let gameName = escapeText(game.name); | ||||
let mapTypeIdx = g_MapTypes.Name.indexOf(game.mapType); | let mapTypeIdx = g_MapTypes.Name.indexOf(game.mapType); | ||||
if (game.ip == g_SelectedGameIP && game.port == g_SelectedGamePort) | if (game.ip == g_SelectedGameIP && game.port == g_SelectedGamePort) | ||||
selectedGameIndex = +i; | selectedGameIndex = +i; | ||||
list_buddy.push(game.hasBuddies ? coloredText(g_BuddySymbol, g_GameColors[game.state]) : ""); | list_buddy.push(game.hasBuddies ? coloredText( | ||||
list_name.push(coloredText(gameName, g_GameColors[game.state])); | game.hasUser ? g_UserSymbol : g_BuddySymbol, | ||||
game.hasUser ? g_UserColor : g_GameColors[game.state]) | |||||
: ""); | |||||
list_name.push(coloredText(gameName, game.hasUser ? g_UserColor : g_GameColors[game.state])); | |||||
list_mapName.push(translateMapTitle(game.niceMapName)); | list_mapName.push(translateMapTitle(game.niceMapName)); | ||||
Done Inline ActionscoloredText redundant with guiTags, ought to be deprecated elexis: coloredText redundant with guiTags, ought to be deprecated | |||||
list_mapSize.push(translateMapSize(game.mapSize)); | list_mapSize.push(translateMapSize(game.mapSize)); | ||||
list_mapType.push(g_MapTypes.Title[mapTypeIdx] || ""); | list_mapType.push(g_MapTypes.Title[mapTypeIdx] || ""); | ||||
list_nPlayers.push(game.nbp + "/" + game.maxnbp); | list_nPlayers.push(game.nbp + "/" + game.maxnbp); | ||||
list_gameRating.push(game.gameRating); | list_gameRating.push(game.gameRating); | ||||
list.push(gameName); | list.push(gameName); | ||||
list_data.push(i); | list_data.push(i); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 477 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
remove empty attributes or set them default color