Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/lobby/lobby.js
Show All 26 Lines | |||||
* Lobby server address to construct host JID. | * Lobby server address to construct host JID. | ||||
*/ | */ | ||||
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": { "style": {}, "buddyStyle": {} }, | ||||
ffffffff: remove empty attributes or set them default color | |||||
"waiting": "255 127 0", | "waiting": { "style": {}, "buddyStyle": {} }, | ||||
"running": "219 0 0" | "running": { "style": {}, "buddyStyle": {} } | ||||
}; | }; | ||||
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 = Object.keys(g_GameColors); | ||||
/** | /** | ||||
* The playerlist will be assembled using these values. | * The playerlist will be assembled using these values. | ||||
*/ | */ | ||||
var g_PlayerStatuses = { | var g_PlayerStatuses = { | ||||
"available": { "color": "0 219 0", "status": translate("Online") }, | "available": { "style": {}, "buddyStyle": {} , "status": translate("Online") }, | ||||
"away": { "color": "229 76 13", "status": translate("Away") }, | "away": { "style": {}, "buddyStyle": {} , "status": translate("Away") }, | ||||
"playing": { "color": "200 0 0", "status": translate("Busy") }, | "playing": { "style": {}, "buddyStyle": {} , "status": translate("Busy") }, | ||||
"offline": { "color": "0 0 0", "status": translate("Offline") }, | "offline": { "style": {}, "buddyStyle": {} , "status": translate("Offline") }, | ||||
"unknown": { "color": "178 178 178", "status": translateWithContext("lobby presence", "Unknown") } | "unknown": { "style": {}, "buddyStyle": {} , "status": translateWithContext("lobby presence", "Unknown") } | ||||
}; | }; | ||||
/** | |||||
* Style for indicating the user in the playerlist and the game where he is listed. | |||||
*/ | |||||
var g_UserStyle; | |||||
var g_RoleNames = { | var g_RoleNames = { | ||||
"moderator": translate("Moderator"), | "moderator": translate("Moderator"), | ||||
"participant": translate("Player"), | "participant": translate("Player"), | ||||
"visitor": translate("Muted Player") | "visitor": translate("Muted Player") | ||||
}; | }; | ||||
/** | /** | ||||
* Color for error messages in the chat. | * Color for error messages in the chat. | ||||
▲ Show 20 Lines • Show All 335 Lines • ▼ Show 20 Lines | function init(attribs) | ||||
g_Dialog = attribs && attribs.dialog; | g_Dialog = attribs && attribs.dialog; | ||||
if (!g_Settings) | if (!g_Settings) | ||||
{ | { | ||||
leaveLobby(); | leaveLobby(); | ||||
return; | return; | ||||
} | } | ||||
readConfigStatusColors(); | |||||
initMusic(); | initMusic(); | ||||
global.music.setState(global.music.states.MENU); | global.music.setState(global.music.states.MENU); | ||||
initDialogStyle(); | initDialogStyle(); | ||||
initGameFilters(); | initGameFilters(); | ||||
updateConnectedState(); | updateConnectedState(); | ||||
Engine.LobbySetPlayerPresence("available"); | Engine.LobbySetPlayerPresence("available"); | ||||
▲ Show 20 Lines • Show All 66 Lines • ▼ Show 20 Lines | |||||
function updateConnectedState() | function updateConnectedState() | ||||
{ | { | ||||
Engine.GetGUIObjectByName("chatInput").hidden = !Engine.IsXmppClientConnected(); | Engine.GetGUIObjectByName("chatInput").hidden = !Engine.IsXmppClientConnected(); | ||||
for (let button of ["host", "leaderboard", "userprofile", "toggleBuddy"]) | for (let button of ["host", "leaderboard", "userprofile", "toggleBuddy"]) | ||||
Engine.GetGUIObjectByName(button + "Button").enabled = Engine.IsXmppClientConnected(); | Engine.GetGUIObjectByName(button + "Button").enabled = Engine.IsXmppClientConnected(); | ||||
} | } | ||||
function readConfigStatusColors() | |||||
Not Done Inline Actionssome valdidate color test ffffffff: some valdidate color test | |||||
{ | |||||
for (let i in g_GameColors) | |||||
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... | |||||
g_GameColors[i].style = { "color": isValidColor(Engine.ConfigDB_GetValue("user", "lobby.statuscolors.games." + i)) }; | |||||
g_GameColors[i].buddyStyle = { "color": isValidColor(Engine.ConfigDB_GetValue("user", "lobby.statuscolors.games.buddy." + i)) }; | |||||
} | |||||
Done Inline Actionssame elexis: same | |||||
for (let i in g_PlayerStatuses) | |||||
{ | |||||
g_PlayerStatuses[i].style = { "color": isValidColor(Engine.ConfigDB_GetValue("user", "lobby.statuscolors.players." + i)) }; | |||||
g_PlayerStatuses[i].buddyStyle = { "color": isValidColor(Engine.ConfigDB_GetValue("user", "lobby.statuscolors.players.buddy." + i)) }; | |||||
} | |||||
g_UserStyle = { "color": isValidColor(Engine.ConfigDB_GetValue("user", "lobby.userplayer.color")) }; | |||||
} | |||||
function updateLobbyColumns() | function updateLobbyColumns() | ||||
{ | { | ||||
let gameRating = Engine.ConfigDB_GetValue("user", "lobby.columns.gamerating") == "true"; | let gameRating = Engine.ConfigDB_GetValue("user", "lobby.columns.gamerating") == "true"; | ||||
// 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; | ||||
gamesBox.hidden_gameRating = !gameRating; | gamesBox.hidden_gameRating = !gameRating; | ||||
▲ Show 20 Lines • Show All 190 Lines • ▼ Show 20 Lines | function updateToggleBuddy() | ||||
toggleBuddyButton.enabled = playerName && playerName != g_Username; | toggleBuddyButton.enabled = playerName && playerName != g_Username; | ||||
} | } | ||||
/** | /** | ||||
* 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; | ||||
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; | ||||
let highlightedBuddy = Engine.ConfigDB_GetValue("user", "lobby.highlightbuddies") == "true"; | |||||
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 = [{name:"Feldfeld", presence:"playing", rating:"1842", role:"participant", isBuddy:true, isUser:false}, {name:"Liberty", presence:"available", rating:"1733", role:"participant", isBuddy:true, isUser:false}, {name:"PhyZic", presence:"playing", rating:"1724", role:"participant", isBuddy:true, isUser:false}, {name:"chrstgtr", presence:"playing", rating:"1657", role:"participant", isBuddy:true, isUser:false}, {name:"_zoro_", presence:"playing", rating:"1649", role:"participant", isBuddy:true, isUser:false}, {name:"nigel87", presence:"playing", rating:"1560", role:"participant", isBuddy:true, isUser:false}, {name:"camelius", presence:"playing", rating:"1525", role:"participant", isBuddy:true, isUser:false}, {name:"K4OS", presence:"playing", rating:"1457", role:"participant", isBuddy:true, isUser:false}, {name:"(-_-)", presence:"playing", rating:"1412", role:"participant", isBuddy:true, isUser:false}, {name:"mord", presence:"playing", rating:"1248", role:"participant", isBuddy:true, isUser:false}, {name:"phoenixdesk", presence:"playing", rating:"1242", role:"participant", isBuddy:true, isUser:false}, {name:"Beboo", presence:"playing", rating:"861", role:"participant", isBuddy:true, isUser:false}, {name:"FFFFFFF8", presence:"available", rating:"", role:"participant", isBuddy:true, isUser:false}, {name:"fsvn", presence:"available", rating:"", role:"participant", isBuddy:false, isUser:true}, {name:"mapkoc", presence:"away", rating:"", role:"moderator", isBuddy:true, isUser:false}, {name:"Grugnas", presence:"away", rating:"", role:"participant", isBuddy:true, isUser:false}, {name:"elexis", presence:"playing", rating:"", role:"moderator", isBuddy:true, isUser:false}, {name:"Hannibal_Baraq", presence:"playing", rating:"", role:"moderator", isBuddy:true, isUser:false}, {name:"user1", presence:"playing", rating:"", role:"moderator", isBuddy:true, isUser:false}, {name:"Hannibal_Barca", presence:"playing", rating:"1641", role:"participant", isBuddy:false, isUser:false}, {name:"mo", presence:"playing", rating:"1435", role:"participant", isBuddy:false, isUser:false}, {name:"googly_eyed_gator", presence:"playing", rating:"1381", role:"participant", isBuddy:false, isUser:false}, {name:"thenu", presence:"playing", rating:"1348", role:"participant", isBuddy:false, isUser:false}, {name:"Pluft", presence:"playing", rating:"1332", role:"participant", isBuddy:false, isUser:false}, {name:"lils", presence:"playing", rating:"1308", role:"participant", isBuddy:false, isUser:false}, {name:"ycswyw", presence:"available", rating:"1305", role:"participant", isBuddy:false, isUser:false}, {name:"JohnnyFresh", presence:"playing", rating:"1302", role:"participant", isBuddy:false, isUser:false}, {name:"Macaco", presence:"playing", rating:"1302", role:"participant", isBuddy:false, isUser:false}, {name:"LUPOX", presence:"playing", rating:"1292", role:"participant", isBuddy:false, isUser:false}, {name:"xdgamer", presence:"playing", rating:"1272", role:"participant", isBuddy:false, isUser:false}, {name:"Leoland", presence:"playing", rating:"1270", role:"participant", isBuddy:false, isUser:false}, {name:"aristide", presence:"available", rating:"1265", role:"participant", isBuddy:false, isUser:false}, {name:"xxcaedesxx2017", presence:"playing", rating:"1265", role:"participant", isBuddy:false, isUser:false}, {name:"theway", presence:"playing", rating:"1258", role:"participant", isBuddy:false, isUser:false}, {name:"mattipenna", presence:"playing", rating:"1257", role:"participant", isBuddy:false, isUser:false}, {name:"albertSBD", presence:"playing", rating:"1256", role:"participant", isBuddy:false, isUser:false}, {name:"Mr._P._Ness", presence:"playing", rating:"1246", role:"participant", isBuddy:false, isUser:false}, {name:"ezkiboi", presence:"playing", rating:"1220", role:"participant", isBuddy:false, isUser:false}, {name:"juniormaster", presence:"playing", rating:"1220", role:"participant", isBuddy:false, isUser:false}, {name:"mesakaro", presence:"playing", rating:"1197", role:"participant", isBuddy:false, isUser:false}, {name:"hereIam", presence:"playing", rating:"1180", role:"participant", isBuddy:false, isUser:false}, {name:"worwuk2", presence:"available", rating:"1174", role:"participant", isBuddy:false, isUser:false}, {name:"Poseidongr", presence:"playing", rating:"1168", role:"participant", isBuddy:false, isUser:false}, {name:"fernando1993", presence:"available", rating:"1167", role:"participant", isBuddy:false, isUser:false}, {name:"Edwarf", presence:"playing", rating:"1161", role:"participant", isBuddy:false, isUser:false}, {name:"MMGamer", presence:"available", rating:"1153", role:"participant", isBuddy:false, isUser:false}, {name:"karajme", presence:"available", rating:"1143", role:"participant", isBuddy:false, isUser:false}, {name:"JordiStc2", presence:"playing", rating:"1136", role:"participant", isBuddy:false, isUser:false}, {name:"alles", presence:"playing", rating:"1134", role:"participant", isBuddy:false, isUser:false}, {name:"Castri_sbd", presence:"playing", rating:"1107", role:"participant", isBuddy:false, isUser:false}, {name:"davidholmes", presence:"playing", rating:"1094", role:"participant", isBuddy:false, isUser:false}, {name:"GameStudio51", presence:"playing", rating:"1091", role:"participant", isBuddy:false, isUser:false}, {name:"cocoloco", presence:"playing", rating:"1062", role:"participant", isBuddy:false, isUser:false}, {name:"IrisRelay", presence:"playing", rating:"1022", role:"participant", isBuddy:false, isUser:false}, {name:"silius117", presence:"playing", rating:"1016", role:"participant", isBuddy:false, isUser:false}, {name:"Lupingo8", presence:"playing", rating:"992", role:"participant", isBuddy:false, isUser:false}, {name:"Ratings", presence:"available", rating:"", role:"moderator", isBuddy:false, isUser:false}, {name:"WFGbot", presence:"available", rating:"", role:"moderator", isBuddy:false, isUser:false}, {name:"Babavoi2", presence:"available", rating:"", role:"participant", isBuddy:false, isUser:false}, {name:"Belze", presence:"available", rating:"", role:"participant", isBuddy:false, isUser:false}, {name:"DontFearTheReaper", presence:"available", rating:"", role:"participant", isBuddy:false, isUser:false}, {name:"Dunedan", presence:"available", rating:"", role:"participant", isBuddy:false, isUser:false}, {name:"Aragorn1212", presence:"playing", rating:"", role:"participant", isBuddy:false, isUser:false}, {name:"Artas13400", presence:"playing", rating:"", role:"participant", isBuddy:false, isUser:false}, {name:"audedu35", presence:"playing", rating:"", role:"participant", isBuddy:false, isUser:false}, {name:"cyrus1er", presence:"playing", rating:"", role:"participant", isBuddy:false, isUser:false}, {name:"Exqua", presence:"playing", rating:"", role:"participant", isBuddy:false, isUser:false}, {name:"Felillop", presence:"playing", rating:"", role:"participant", isBuddy:false, isUser:false}, {name:"J3nder", presence:"playing", rating:"", role:"participant", isBuddy:false, isUser:false}, {name:"javillop", presence:"playing", rating:"", role:"participant", isBuddy:false, isUser:false}, {name:"Jojodio", presence:"playing", rating:"", role:"participant", isBuddy:false, isUser:false}, {name:"Kamilues", presence:"playing", rating:"", role:"participant", isBuddy:false, isUser:false}, {name:"kar23", presence:"playing", rating:"", role:"participant", isBuddy:false, isUser:false}, {name:"Kotus", presence:"playing", rating:"", role:"participant", isBuddy:false, isUser:false}, {name:"Krytecks", presence:"playing", rating:"", role:"participant", isBuddy:false, isUser:false}, {name:"LapizLopez", presence:"playing", rating:"", role:"participant", isBuddy:false, isUser:false}, {name:"LateinCecker", presence:"playing", rating:"", role:"participant", isBuddy:false, isUser:false}, {name:"Lord_Blop", presence:"playing", rating:"", role:"participant", isBuddy:false, isUser:false}, {name:"Pablopr3", presence:"playing", rating:"", role:"participant", isBuddy:false, isUser:false}, {name:"Platon", presence:"playing", rating:"", role:"participant", isBuddy:false, isUser:false}, {name:"rogeRabbit", presence:"playing", rating:"", role:"participant", isBuddy:false, isUser:false}, {name:"WARAP_PIMP", presence:"playing", rating:"", role:"participant", isBuddy:false, isUser:false}, {name:"wojxik", presence:"playing", rating:"", role:"participant", isBuddy:false, isUser:false}].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 statusStyle = highlightedBuddy && player.name == g_Username ? g_UserStyle : | ||||
buddyStatusList.push(player.isBuddy ? coloredText(g_BuddySymbol, statusColor) : ""); | highlightedBuddy && player.isBuddy ? g_PlayerStatuses[presence].buddyStyle : | ||||
g_PlayerStatuses[presence].style; | |||||
buddyStatusList.push(player.isBuddy ? setStringTags(g_BuddySymbol, statusStyle) : ""); | |||||
Done Inline ActionsDon't colorize the empty string elexis: Don't colorize the empty string | |||||
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(setStringTags(g_PlayerStatuses[presence].status, statusStyle)); | ||||
ratingList.push(coloredText(rating, statusColor)); | ratingList.push(setStringTags(rating, statusStyle)); | ||||
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; | ||||
playersBox.list = nickList; | playersBox.list = nickList; | ||||
▲ Show 20 Lines • Show All 217 Lines • ▼ Show 20 Lines | |||||
/** | /** | ||||
* Update the game listing from data cached in C++. | * Update the game listing from data cached in C++. | ||||
*/ | */ | ||||
function updateGameList() | function updateGameList() | ||||
{ | { | ||||
let gamesBox = Engine.GetGUIObjectByName("gamesBox"); | let gamesBox = Engine.GetGUIObjectByName("gamesBox"); | ||||
let sortBy = gamesBox.selected_column; | let sortBy = gamesBox.selected_column; | ||||
let sortOrder = gamesBox.selected_column_order; | let sortOrder = gamesBox.selected_column_order; | ||||
let highlightedBuddy = Engine.ConfigDB_GetValue("user", "lobby.highlightbuddies") == "true"; | |||||
if (gamesBox.selected > -1) | if (gamesBox.selected > -1) | ||||
{ | { | ||||
g_SelectedGameIP = g_GameList[gamesBox.selected].ip; | g_SelectedGameIP = g_GameList[gamesBox.selected].ip; | ||||
g_SelectedGamePort = g_GameList[gamesBox.selected].port; | g_SelectedGamePort = g_GameList[gamesBox.selected].port; | ||||
} | } | ||||
g_GameList = Engine.GetGameList().map(game => { | g_GameList = [{name:"Grugnas's game", ip:"2.226.121.239", port:"20595", stunIP:"2.226.121.239", stunPort:"60195", hostUsername:"Grugnas", state:"init", nbp:"8", maxnbp:"8", players:"{\"-1\":\\[{\"Name\":\"PhyZic (1724)\"},{\"Name\":\"Feldfeld (1842)\"},{\"Name\":\"Hannibal_Barca (1641)\"},{\"Name\":\"chrstgtr (1657)\"},{\"Name\":\"Grugnas\"},{\"Name\":\"ycswyw (1305)\"},{\"Name\":\"phoenixdesk (1242)\"},{\"Name\":\"K4OS (1457)\"}],\"observer\":\\[{\"Name\":\"xdgamer (1272)\",\"Team\":\"observer\"},{\"Name\":\"samba (1159)\",\"Team\":\"observer\"},{\"Name\":\"Hercules55 (1262)\",\"Team\":\"observer\"},{\"Name\":\"mapkoc\",\"Team\":\"observer\"},{\"Name\":\"_zoro_ (1649)\",\"Team\":\"observer\"},{\"Name\":\"mattipenna (1257)\",\"Team\":\"observer\"},{\"Name\":\"nigel87 (1560)\",\"Team\":\"observer\"},{\"Name\":\"camelius (1525)\",\"Team\":\"observer\"},{\"Name\":\"rogeRabbit\",\"Team\":\"observer\"}]}", mapName:"maps/random/rivers", niceMapName:"Rivers", mapSize:"320", mapType:"random", victoryCondition:"conquest", startTime:"", hasBuddies:2, teamPlayers:{'-1':8}, teamPlayersOrg:{'-1':8}, noTeam:0, observerNum:9, buddySymbol:2, buddyNum:6, playerFilterFound:0, gameRating:1509}, {name:"1v1", ip:"202.153.80.114", port:"20595", stunIP:"202.153.80.114", stunPort:"6936", hostUsername:"(-_-)", state:"running", nbp:"2", maxnbp:"2", players:"{\"0\":\\[{\"Name\":\"(-_-) (1412)\",\"Team\":0}],\"1\":\\[{\"Name\":\"silius117 (1016)\",\"Team\":1}]}", mapName:"maps/random/mainland", niceMapName:"Mainland", mapSize:"192", mapType:"random", victoryCondition:"conquest", startTime:"1504891845", hasBuddies:2, teamPlayers:{0:1, 1:1}, teamPlayersOrg:{0:1, 1:1}, noTeam:0, observerNum:0, buddySymbol:2, buddyNum:1, playerFilterFound:0, gameRating:1214}, {name:"ezkiboi's game", ip:"86.4.116.222", port:"20595", stunIP:"86.4.116.222", stunPort:"20595", hostUsername:"ezkiboi", state:"running", nbp:"2", maxnbp:"2", players:"{\"-1\":\\[{\"Name\":\"ezkiboi\",\"Team\":-1},{\"Name\":\"Beboo (861)\",\"Team\":-1}]}", mapName:"maps/skirmishes/Alpine_Valleys_(2)", niceMapName:"Alpine Valleys (2)", mapSize:"Default", mapType:"skirmish", victoryCondition:"conquest", startTime:"1504892195", hasBuddies:2, teamPlayers:{'-1':2}, teamPlayersOrg:{'-1':2}, noTeam:0, observerNum:0, buddySymbol:2, buddyNum:1, playerFilterFound:0, gameRating:1031}, {name:"mord's game", ip:"77.180.235.85", port:"20595", stunIP:"77.180.235.85", stunPort:"20595", hostUsername:"mord", state:"running", nbp:"4", maxnbp:"4", players:"{\"0\":\\[{\"Name\":\"mord (1248)\",\"Team\":0},{\"Name\":\"Pluft (1332)\",\"Team\":0}],\"1\":\\[{\"Name\":\"mo (1435)\",\"Team\":1},{\"Name\":\"Lord_Blop\",\"Team\":1}]}", mapName:"maps/random/danubius", niceMapName:"Danubius", mapSize:"256", mapType:"random", victoryCondition:"capture_the_relic", startTime:"1504891436", hasBuddies:2, teamPlayers:{0:2, 1:2}, teamPlayersOrg:{0:2, 1:2}, noTeam:0, observerNum:0, buddySymbol:2, buddyNum:1, playerFilterFound:0, gameRating:1304}, {name:"Game of Thrones", ip:"79.26.139.123", port:"20595", stunIP:"79.26.139.123", stunPort:"58246", hostUsername:"ReGeoffrey", state:"init", nbp:"2", maxnbp:"3", players:"{\"observer\":\\[{\"Name\":\"trijeux2005\",\"Team\":\"observer\"},{\"Name\":\"davidholmes (1094)\",\"Team\":\"observer\"}],\"-1\":\\[{\"Name\":\"ReGeoffrey (1159)\"},{\"Name\":\"aristide (1265)\"}]}", mapName:"maps/skirmishes/Gambia River (3)", niceMapName:"Gambia River (3)", mapSize:"Default", mapType:"skirmish", victoryCondition:"conquest", startTime:"", hasBuddies:0, teamPlayers:{'-1':2}, teamPlayersOrg:{'-1':2}, noTeam:0, observerNum:2, buddySymbol:0, buddyNum:0, playerFilterFound:0, gameRating:1212}, {name:"mardukamm's game", ip:"151.63.243.242", port:"20595", stunIP:"151.63.243.242", stunPort:"28321", hostUsername:"mardukamm", state:"init", nbp:"2", maxnbp:"2", players:"{\"-1\":\\[{\"Name\":\"mardukamm\"},{\"Name\":\"Rulii (1189)\"}]}", mapName:"maps/scenarios/Aryanbactria", niceMapName:"Aryanistan", mapSize:"Default", mapType:"scenario", victoryCondition:"endless", startTime:"", hasBuddies:0, teamPlayers:{'-1':2}, teamPlayersOrg:{'-1':2}, noTeam:0, observerNum:0, buddySymbol:0, buddyNum:0, playerFilterFound:0, gameRating:1195}, {name:"Private", ip:"94.66.223.240", port:"20595", stunIP:"94.66.223.240", stunPort:"27971", hostUsername:"hereIam", state:"waiting", nbp:"1", maxnbp:"8", players:"{\"0\":\\[{\"Name\":\"hereIam (1180)\",\"Team\":0},{\"Name\":\"Audax\",\"Team\":0,\"AI\":\"petra\",\"AIDiff\":5},{\"Name\":\"Mago Barca\",\"Team\":0,\"AI\":\"petra\",\"AIDiff\":5},{\"Name\":\"Lucius Junius Brutus\",\"Team\":0,\"AI\":\"petra\",\"AIDiff\":5}],\"1\":\\[{\"Name\":\"juli147 (1050)\",\"Team\":1,\"Offline\":true,\"State\":\"defeated\"},{\"Name\":\"Cingetorix\",\"Team\":1,\"AI\":\"petra\",\"AIDiff\":5},{\"Name\":\"Artaxshacha II\",\"Team\":1,\"AI\":\"petra\",\"AIDiff\":5,\"State\":\"defeated\"},{\"Name\":\"Meleager\",\"Team\":1,\"AI\":\"petra\",\"AIDiff\":5}]}", mapName:"maps/random/marmara", niceMapName:"Marmara", mapSize:"320", mapType:"random", victoryCondition:"conquest_structures", startTime:"1504883800", hasBuddies:0, teamPlayers:{0:4, 1:2}, teamPlayersOrg:{0:4, 1:4}, noTeam:0, observerNum:1, buddySymbol:0, buddyNum:0, playerFilterFound:0, gameRating:1197}, {name:"Private_albert", ip:"81.38.254.175", port:"20595", stunIP:"81.38.254.175", stunPort:"20595", hostUsername:"albertSBD", state:"waiting", nbp:"3", maxnbp:"4", players:"{\"0\":\\[{\"Name\":\"albertSBD (1256)\",\"Team\":0},{\"Name\":\"Castri_sbd (1107)\",\"Team\":0}],\"1\":\\[{\"Name\":\"juniormaster (1220)\",\"Team\":1},{\"Name\":\"ReGeoffrey (1159)\",\"Team\":1,\"Offline\":true,\"State\":\"defeated\"}]}", mapName:"maps/random/guadalquivir_river", niceMapName:"Guadalquivir River", mapSize:"448", mapType:"random", victoryCondition:"conquest", startTime:"1504888757", hasBuddies:0, teamPlayers:{0:2, 1:1}, teamPlayersOrg:{0:2, 1:2}, noTeam:0, observerNum:0, buddySymbol:0, buddyNum:0, playerFilterFound:0, gameRating:1194}, {name:"\u0442\u0430\u0434\u0430\u0434\u0430\u0434\u0430\u043C", ip:"94.141.162.12", port:"20595", stunIP:"94.141.162.12", stunPort:"20595", hostUsername:"alles", state:"waiting", nbp:"1", maxnbp:"3", players:"{\"0\":\\[{\"Name\":\"alles (1134)\",\"Team\":0},{\"Name\":\"Aragorn1212\",\"Team\":0,\"Offline\":true}],\"1\":\\[{\"Name\":\"Kurush II the Great\",\"Team\":1,\"AI\":\"petra\",\"AIDiff\":2}]}", mapName:"maps/random/volcanic_lands", niceMapName:"Volcanic Lands", mapSize:"256", mapType:"random", victoryCondition:"conquest", startTime:"1504891342", hasBuddies:0, teamPlayers:{0:2, 1:1}, teamPlayersOrg:{0:2, 1:1}, noTeam:0, observerNum:0, buddySymbol:0, buddyNum:0, playerFilterFound:0, gameRating:1178}, {name:"1v1 or 2v2 any rating", ip:"72.192.93.80", port:"20595", stunIP:"72.192.93.80", stunPort:"20595", hostUsername:"theway", state:"running", nbp:"2", maxnbp:"2", players:"{\"0\":\\[{\"Name\":\"theway (1258)\",\"Team\":0}],\"1\":\\[{\"Name\":\"Leoland (1270)\",\"Team\":1}]}", mapName:"maps/random/mainland", niceMapName:"Mainland", mapSize:"256", mapType:"random", victoryCondition:"conquest", startTime:"1504891603", hasBuddies:0, teamPlayers:{0:1, 1:1}, teamPlayersOrg:{0:1, 1:1}, noTeam:0, observerNum:0, buddySymbol:0, buddyNum:0, playerFilterFound:0, gameRating:1264}, {name:"cocoloco's game", ip:"187.227.2.232", port:"20595", stunIP:"187.227.2.232", stunPort:"20595", hostUsername:"cocoloco", state:"running", nbp:"4", maxnbp:"4", players:"{\"0\":\\[{\"Name\":\"cocoloco (1062)\",\"Team\":0},{\"Name\":\"JohnnyFresh (1302)\",\"Team\":0}],\"1\":\\[{\"Name\":\"googly_eyed_gator (1381)\",\"Team\":1},{\"Name\":\"LateinCecker\",\"Team\":1}]}", mapName:"maps/random/ardennes_forest", niceMapName:"Ardennes Forest", mapSize:"256", mapType:"random", victoryCondition:"conquest", startTime:"1504890958", hasBuddies:0, teamPlayers:{0:2, 1:2}, teamPlayersOrg:{0:2, 1:2}, noTeam:0, observerNum:0, buddySymbol:0, buddyNum:0, playerFilterFound:0, gameRating:1236}, {name:"javillop's game", ip:"81.38.27.147", port:"20595", stunIP:"81.38.27.147", stunPort:"20595", hostUsername:"javillop", state:"running", nbp:"4", maxnbp:"6", players:"{\"-1\":\\[{\"Name\":\"javillop\"},{\"Name\":\"Felillop\"},{\"Name\":\"WARAP_PIMP\"},{\"Name\":\"Platon\"},{\"Name\":\"Antiochus VI Dionysus\",\"AI\":\"petra\",\"AIDiff\":5},{\"Name\":\"Player 6\"}]}", mapName:"maps/skirmishes/Two Seas (6)", niceMapName:"Two Seas (6)", mapSize:"Default", mapType:"skirmish", victoryCondition:"conquest", startTime:"1504887762", hasBuddies:0, teamPlayers:{'-1':6}, teamPlayersOrg:{'-1':6}, noTeam:0, observerNum:0, buddySymbol:0, buddyNum:0, playerFilterFound:0, gameRating:1200}, {name:"Kamilues's game", ip:"77.253.173.97", port:"20595", stunIP:"77.253.173.97", stunPort:"20595", hostUsername:"Kamilues", state:"running", nbp:"4", maxnbp:"4", players:"{\"0\":\\[{\"Name\":\"Kamilues\",\"Team\":0},{\"Name\":\"wojxik\",\"Team\":0}],\"1\":\\[{\"Name\":\"JordiStc2 (1136)\",\"Team\":1},{\"Name\":\"mesakaro (1197)\",\"Team\":1}]}", mapName:"maps/skirmishes/Greek Acropolis (4)", niceMapName:"Greek Acropolis (4)", mapSize:"Default", mapType:"skirmish", victoryCondition:"conquest", startTime:"1504892395", hasBuddies:0, teamPlayers:{0:2, 1:2}, teamPlayersOrg:{0:2, 1:2}, noTeam:0, observerNum:0, buddySymbol:0, buddyNum:0, playerFilterFound:0, gameRating:1183}, {name:"lils's game", ip:"84.238.145.154", port:"20595", stunIP:"84.238.145.154", stunPort:"20595", hostUsername:"lils", state:"running", nbp:"2", maxnbp:"2", players:"{\"-1\":\\[{\"Name\":\"GameStudio51 (1091)\",\"Team\":-1},{\"Name\":\"lils (1308)\",\"Team\":-1}]}", mapName:"maps/skirmishes/Death Canyon (2)", niceMapName:"Death Canyon (2)", mapSize:"Default", mapType:"skirmish", victoryCondition:"conquest_structures", startTime:"1504890275", hasBuddies:0, teamPlayers:{'-1':2}, teamPlayersOrg:{'-1':2}, noTeam:0, observerNum:0, buddySymbol:0, buddyNum:0, playerFilterFound:0, gameRating:1200}, | ||||
{name:"Lupingo8's game", ip:"90.69.13.16", port:"20595", stunIP:"90.69.13.16", stunPort:"20595", hostUsername:"Lupingo8", state:"running", nbp:"2", maxnbp:"2", players:"{\"-1\":\\[{\"Name\":\"Lupingo8 (992)\",\"Team\":-1},{\"Name\":\"LUPOX (1292)\",\"Team\":-1}]}", mapName:"maps/skirmishes/Golden Island (2)", niceMapName:"Golden Island (2)", mapSize:"Default", mapType:"skirmish", victoryCondition:"conquest", startTime:"1504890679", hasBuddies:0, teamPlayers:{'-1':2}, teamPlayersOrg:{'-1':2}, noTeam:0, observerNum:0, buddySymbol:0, buddyNum:0, playerFilterFound:0, gameRating:1142}, {name:"Pablopr3's game", ip:"83.47.54.83", port:"20595", stunIP:"83.47.54.83", stunPort:"20595", hostUsername:"Pablopr3", state:"running", nbp:"2", maxnbp:"4", players:"{\"0\":\\[{\"Name\":\"Pablopr3\",\"Team\":0},{\"Name\":\"Jojodio\",\"Team\":0}],\"1\":\\[{\"Name\":\"Demosthenes\",\"Team\":1,\"AI\":\"petra\",\"AIDiff\":3},{\"Name\":\"Darayavahush II\",\"Team\":1,\"AI\":\"petra\",\"AIDiff\":3}]}", mapName:"maps/skirmishes/Forest Battle (4)", niceMapName:"Forest Battle (4)", mapSize:"Default", mapType:"skirmish", victoryCondition:"conquest", startTime:"1504891967", hasBuddies:0, teamPlayers:{0:2, 1:2}, teamPlayersOrg:{0:2, 1:2}, noTeam:0, observerNum:0, buddySymbol:0, buddyNum:0, playerFilterFound:0, gameRating:1200}, {name:"Poseidongr's game", ip:"85.72.236.78", port:"20595", stunIP:"85.72.236.78", stunPort:"20595", hostUsername:"Poseidongr", state:"running", nbp:"2", maxnbp:"2", players:"{\"-1\":\\[{\"Name\":\"Poseidongr (1168)\",\"Team\":-1},{\"Name\":\"Macaco (1302)\",\"Team\":-1}]}", mapName:"maps/random/hells_pass", niceMapName:"Hell's Pass", mapSize:"448", mapType:"random", victoryCondition:"conquest", startTime:"1504889563", hasBuddies:0, teamPlayers:{'-1':2}, teamPlayersOrg:{'-1':2}, noTeam:0, observerNum:0, buddySymbol:0, buddyNum:0, playerFilterFound:0, gameRating:1235}, {name:"PRIVATE", ip:"82.193.253.7", port:"20595", stunIP:"82.193.253.7", stunPort:"20595", hostUsername:"xxcaedesxx2017", state:"running", nbp:"2", maxnbp:"6", players:"{\"-1\":\\[{\"Name\":\"xxcaedesxx2017 (1265)\",\"Team\":-1},{\"Name\":\"J3nder\",\"Team\":-1},{\"Name\":\"Karatakos\",\"Team\":-1,\"AI\":\"petra\",\"AIDiff\":2},{\"Name\":\"Kunobelinos\",\"Team\":-1,\"AI\":\"petra\",\"AIDiff\":2},{\"Name\":\"Xsayarsa I\",\"Team\":-1,\"AI\":\"petra\",\"AIDiff\":2},{\"Name\":\"Ptolemy Epigone\",\"Team\":-1,\"AI\":\"petra\",\"AIDiff\":2}]}", mapName:"maps/skirmishes/Two Seas (6)", niceMapName:"Two Seas (6)", mapSize:"Default", mapType:"skirmish", victoryCondition:"conquest", startTime:"1504889619", hasBuddies:0, teamPlayers:{'-1':6}, teamPlayersOrg:{'-1':6}, noTeam:0, observerNum:0, buddySymbol:0, buddyNum:0, playerFilterFound:0, gameRating:1211}].map(game => { | |||||
game.hasBuddies = 0; | game.hasBuddies = 0; | ||||
// Compute average rating of participating players | // Compute average rating of participating players | ||||
let playerRatings = []; | let playerRatings = []; | ||||
for (let player of stringifiedTeamListToPlayerData(game.players)) | for (let player of stringifiedTeamListToPlayerData(game.players)) | ||||
{ | { | ||||
let playerNickRating = splitRatingFromNick(player.Name); | let playerNickRating = splitRatingFromNick(player.Name); | ||||
if (player.Team != "observer") | if (player.Team != "observer") | ||||
playerRatings.push(playerNickRating.rating || g_DefaultLobbyRating); | playerRatings.push(playerNickRating.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(playerNickRating.nick) != -1) | if (game.hasBuddies < 2 && g_Buddies.indexOf(playerNickRating.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 ? setStringTags( | ||||
list_name.push(coloredText(gameName, g_GameColors[game.state])); | g_BuddySymbol, | ||||
highlightedBuddy && game.hasUser ? g_UserStyle : | |||||
highlightedBuddy && game.hasBuddies ? g_GameColors[game.state].buddyStyle : | |||||
g_GameColors[game.state].style) | |||||
: ""); | |||||
Done Inline ActionscoloredText redundant with guiTags, ought to be deprecated elexis: coloredText redundant with guiTags, ought to be deprecated | |||||
list_name.push(setStringTags(gameName, highlightedBuddy && game.hasUser ? g_UserStyle : | |||||
highlightedBuddy && game.hasBuddies ? g_GameColors[game.state].buddyStyle : g_GameColors[game.state].style)); | |||||
list_mapName.push(translateMapTitle(game.niceMapName)); | list_mapName.push(translateMapTitle(game.niceMapName)); | ||||
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 480 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
remove empty attributes or set them default color