Changeset View
Standalone View
binaries/data/mods/public/gui/lobby/lobby.js
Show First 20 Lines • Show All 104 Lines • ▼ Show 20 Lines | |||||
*/ | */ | ||||
var g_SelectedGamePort = ""; | var g_SelectedGamePort = ""; | ||||
/** | /** | ||||
* Whether the current user has been kicked or banned. | * Whether the current user has been kicked or banned. | ||||
*/ | */ | ||||
var g_Kicked = false; | var g_Kicked = false; | ||||
/** | /** | ||||
* Processing of notifications sent by XmppClient.cpp. | * Processing of notifications sent by XmppClient.cpp. | ||||
JoshuaJB: It might be good to rethink how you're doing this so that you don't need all the "return true"s… | |||||
* | * | ||||
* @returns true if the playerlist GUI must be updated. | * @returns true if the playerlist GUI must be updated. | ||||
*/ | */ | ||||
var g_NetMessageTypes = { | var g_NetMessageTypes = { | ||||
"system": { | "system": { | ||||
// Three cases are handled in prelobby.js | // Three cases are handled in prelobby.js | ||||
"registered": msg => false, | "registered": msg => false, | ||||
"connected": msg => false, | "connected": msg => false, | ||||
▲ Show 20 Lines • Show All 273 Lines • ▼ Show 20 Lines | function init(attribs) | ||||
updateLobbyColumns(); | updateLobbyColumns(); | ||||
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); | ||||
if (Engine.ConfigDB_GetValue("user", "lobby.hideprofile") == "true") | |||||
profilePanelHidden(true); | |||||
Done Inline ActionsAgain, no need for configurability. Opinionated design is not a bad thing JoshuaJB: Again, no need for configurability. Opinionated design is not a bad thing | |||||
} | } | ||||
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"); | ||||
Show All 12 Lines | function updateLobbyColumns() | ||||
size.rleft = gameRating ? 74 : 90; | size.rleft = gameRating ? 74 : 90; | ||||
size.rright = gameRating ? 84 : 100; | size.rright = gameRating ? 84 : 100; | ||||
playersNumberFilter.size = size; | playersNumberFilter.size = size; | ||||
} | } | ||||
function returnToMainMenu() | function returnToMainMenu() | ||||
{ | { | ||||
Engine.StopXmppClient(); | Engine.StopXmppClient(); | ||||
Engine.SwitchGuiPage("page_pregame.xml"); | Engine.SwitchGuiPage("page_pregame.xml"); | ||||
Done Inline ActionsThis doesn't add anything to the value of the function. It will only ever return true, so having it return anything at all is pointless. JoshuaJB: This doesn't add anything to the value of the function. It will only ever return true, so… | |||||
} | } | ||||
function initGameFilters() | function initGameFilters() | ||||
{ | { | ||||
let mapSizeFilter = Engine.GetGUIObjectByName("mapSizeFilter"); | let mapSizeFilter = Engine.GetGUIObjectByName("mapSizeFilter"); | ||||
mapSizeFilter.list = [translateWithContext("map size", "Any")].concat(g_MapSizes.Name); | mapSizeFilter.list = [translateWithContext("map size", "Any")].concat(g_MapSizes.Name); | ||||
mapSizeFilter.list_data = [""].concat(g_MapSizes.Tiles); | mapSizeFilter.list_data = [""].concat(g_MapSizes.Tiles); | ||||
▲ Show 20 Lines • Show All 165 Lines • ▼ Show 20 Lines | function updatePlayerList() | ||||
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 = [{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}]; | ||||
cleanPlayerList = cleanPlayerList.map(player => { | |||||
player.isBuddy = g_Buddies.indexOf(player.name) != -1; | player.isBuddy = g_Buddies.indexOf(player.name) != -1; | ||||
Not Done Inline ActionsI don't think you meant to include this change. If you did, some explanation would help JoshuaJB: I don't think you meant to include this change. If you did, some explanation would help | |||||
Not Done Inline Actionstest data. omit on commit. ffffffff: test data. omit on commit. | |||||
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(); | ||||
switch (sortBy) | switch (sortBy) | ||||
▲ Show 20 Lines • Show All 109 Lines • ▼ Show 20 Lines | for (let player of stringifiedTeamListToPlayerData(g_GameList[i].players)) | ||||
else if (!foundAsObserver) | else if (!foundAsObserver) | ||||
gameList.selected = i; | gameList.selected = i; | ||||
} | } | ||||
} | } | ||||
function onPlayerListSelection() | function onPlayerListSelection() | ||||
{ | { | ||||
let playerList = Engine.GetGUIObjectByName("playersBox"); | let playerList = Engine.GetGUIObjectByName("playersBox"); | ||||
if (playerList.selected == playerList.list.indexOf(g_SelectedPlayer)) | if (playerList.selected == -1 || playerList.selected == playerList.list.indexOf(g_SelectedPlayer)) | ||||
Not Done Inline ActionsNice optimization! JoshuaJB: Nice optimization! | |||||
return; | return; | ||||
g_SelectedPlayer = playerList.list[playerList.selected]; | g_SelectedPlayer = playerList.list[playerList.selected]; | ||||
lookupSelectedUserProfile("playersBox"); | lookupSelectedUserProfile("playersBox"); | ||||
updateToggleBuddy(); | updateToggleBuddy(); | ||||
Not Done Inline ActionsGot bug this better as g_SelectedPlayer should be set undefined. on selected = -1; ffffffff: Got bug this better as g_SelectedPlayer should be set undefined. on selected = -1; | |||||
selectGameFromPlayername(); | selectGameFromPlayername(); | ||||
} | } | ||||
function setLeaderboardVisibility(visible) | function setLeaderboardVisibility(visible) | ||||
{ | { | ||||
if (visible) | if (visible) | ||||
Engine.SendGetBoardList(); | Engine.SendGetBoardList(); | ||||
lookupSelectedUserProfile(visible ? "leaderboardBox" : "playersBox"); | lookupSelectedUserProfile(visible ? "leaderboardBox" : "playersBox"); | ||||
Engine.GetGUIObjectByName("leaderboard").hidden = !visible; | Engine.GetGUIObjectByName("leaderboard").hidden = !visible; | ||||
Engine.GetGUIObjectByName("fade").hidden = !visible; | Engine.GetGUIObjectByName("fade").hidden = !visible; | ||||
} | } | ||||
Done Inline ActionsSame comment as on L531 JoshuaJB: Same comment as on L531 | |||||
function setUserProfileVisibility(visible) | function setUserProfileVisibility(visible) | ||||
{ | { | ||||
Engine.GetGUIObjectByName("profileFetch").hidden = !visible; | Engine.GetGUIObjectByName("profileFetch").hidden = !visible; | ||||
Engine.GetGUIObjectByName("fade").hidden = !visible; | Engine.GetGUIObjectByName("fade").hidden = !visible; | ||||
} | } | ||||
Done Inline ActionsSame comment as on L531 JoshuaJB: Same comment as on L531 | |||||
/** | /** | ||||
* Display the profile of the player in the user profile window. | * Display the profile of the player in the user profile window. | ||||
*/ | */ | ||||
function lookupUserProfile() | function lookupUserProfile() | ||||
{ | { | ||||
Engine.SendGetProfile(Engine.GetGUIObjectByName("fetchInput").caption); | Engine.SendGetProfile(Engine.GetGUIObjectByName("fetchInput").caption); | ||||
} | } | ||||
function profilePanelHidden(hidden) | |||||
Done Inline ActionsCould you name this something more descriptive? Maybe "setUserProfilePanelVisibility"? JoshuaJB: Could you name this something more descriptive? Maybe "setUserProfilePanelVisibility"? | |||||
Not Done Inline ActionsIt sets whole left panel size. So instead of setting size in xml we set it now here. Therefore name it setLeftPanelStyle. Same as in D817 function initDialogStyle(). ffffffff: It sets whole left panel size. So instead of setting size in xml we set it now here. Therefore… | |||||
Not Done Inline ActionsHow about setLeftPanelExpanded then? I would mostly just like the call on L900 to be a bit more self-explanatory. JoshuaJB: How about `setLeftPanelExpanded` then? I would mostly just like the call on L900 to be a bit… | |||||
Not Done Inline Actionsy ffffffff: y
indeed | |||||
{ | |||||
if (hidden) | |||||
{ | |||||
Engine.GetGUIObjectByName("profilePanel").hidden = true; | |||||
Engine.GetGUIObjectByName("leftPanel").size = "20 30 20% 100%-110"; | |||||
} | |||||
else | |||||
{ | |||||
Engine.GetGUIObjectByName("profilePanel").hidden = false; | |||||
Engine.GetGUIObjectByName("leftPanel").size = "20 30 20% 100%-310"; | |||||
} | |||||
} | |||||
/** | /** | ||||
* Display the profile of the selected player in the main window. | * Display the profile of the selected player in the main window. | ||||
* 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. | ||||
*/ | */ | ||||
function lookupSelectedUserProfile(guiObjectName) | function lookupSelectedUserProfile(guiObjectName) | ||||
{ | { | ||||
let playerList = Engine.GetGUIObjectByName(guiObjectName); | let playerList = Engine.GetGUIObjectByName(guiObjectName); | ||||
let playerName = playerList.list[playerList.selected]; | let playerName = playerList.list[playerList.selected]; | ||||
Engine.GetGUIObjectByName("profileArea").hidden = !playerName && !Engine.GetGUIObjectByName("usernameText").caption; | Engine.GetGUIObjectByName("profileArea").hidden = !playerName && !Engine.GetGUIObjectByName("usernameText").caption; | ||||
if (!playerName) | if (!playerName) | ||||
return; | return; | ||||
profilePanelHidden(false); | |||||
Engine.SendGetProfile(playerName); | Engine.SendGetProfile(playerName); | ||||
Engine.GetGUIObjectByName("usernameText").caption = playerName; | Engine.GetGUIObjectByName("usernameText").caption = playerName; | ||||
Engine.GetGUIObjectByName("rankText").caption = translate("N/A"); | Engine.GetGUIObjectByName("rankText").caption = translate("N/A"); | ||||
Engine.GetGUIObjectByName("highestRatingText").caption = translate("N/A"); | Engine.GetGUIObjectByName("highestRatingText").caption = translate("N/A"); | ||||
Engine.GetGUIObjectByName("totalGamesText").caption = translate("N/A"); | Engine.GetGUIObjectByName("totalGamesText").caption = translate("N/A"); | ||||
Engine.GetGUIObjectByName("winsText").caption = translate("N/A"); | Engine.GetGUIObjectByName("winsText").caption = translate("N/A"); | ||||
Engine.GetGUIObjectByName("lossesText").caption = translate("N/A"); | Engine.GetGUIObjectByName("lossesText").caption = translate("N/A"); | ||||
▲ Show 20 Lines • Show All 103 Lines • ▼ Show 20 Lines | function updateGameList() | ||||
let sortOrder = gamesBox.selected_column_order; | let sortOrder = gamesBox.selected_column_order; | ||||
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}]; | ||||
g_GameList = g_GameList.map(game => { | |||||
Not Done Inline ActionsI don't think you meant to include this change. If you did, some explanation would help JoshuaJB: I don't think you meant to include this change. If you did, some explanation would help | |||||
Not Done Inline Actionsonly test data can be omited on commit ffffffff: only test data can be omited on commit | |||||
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)) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | function updateGameList() | ||||
let selectedGameIndex = -1; | let selectedGameIndex = -1; | ||||
for (let i in g_GameList) | for (let i in g_GameList) | ||||
{ | { | ||||
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 (gamesBox.selected > -1 && 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(g_BuddySymbol, g_GameColors[game.state]) : ""); | ||||
list_name.push(coloredText(gameName, g_GameColors[game.state])); | list_name.push(coloredText(gameName, g_GameColors[game.state])); | ||||
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); | ||||
▲ Show 20 Lines • Show All 73 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
let gamesBox = Engine.GetGUIObjectByName("gamesBox"); | let gamesBox = Engine.GetGUIObjectByName("gamesBox"); | ||||
if (gamesBox.selected < 0) | if (gamesBox.selected < 0) | ||||
return undefined; | return undefined; | ||||
return g_GameList[gamesBox.list_data[gamesBox.selected]]; | return g_GameList[gamesBox.list_data[gamesBox.selected]]; | ||||
} | } | ||||
/** | /** | ||||
Not Done Inline ActionssetListBoxesUnselected() ffffffff: setListBoxesUnselected() | |||||
* Immediately rejoin and join gamesetups. Otherwise confirm late-observer join attempt. | * Immediately rejoin and join gamesetups. Otherwise confirm late-observer join attempt. | ||||
*/ | */ | ||||
function joinButton() | function joinButton() | ||||
{ | { | ||||
Done Inline ActionsShould these globals not update automatically after the following two deselects? If not, an event-driven model like that would probably be favorable. JoshuaJB: Should these globals not update automatically after the following two deselects?
If not, an… | |||||
let game = selectedGame(); | let game = selectedGame(); | ||||
if (!game) | if (!game) | ||||
return; | return; | ||||
let rating = getRejoinRating(game); | let rating = getRejoinRating(game); | ||||
let username = rating ? g_Username + " (" + rating + ")" : g_Username; | let username = rating ? g_Username + " (" + rating + ")" : g_Username; | ||||
if (game.state == "init" || stringifiedTeamListToPlayerData(game.players).some(player => player.Name == username)) | if (game.state == "init" || stringifiedTeamListToPlayerData(game.players).some(player => player.Name == username)) | ||||
▲ Show 20 Lines • Show All 380 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
if (!attr.totalGamesPlayed) | if (!attr.totalGamesPlayed) | ||||
return translateWithContext("Used for an undefined winning rate", "-"); | return translateWithContext("Used for an undefined winning rate", "-"); | ||||
return sprintf(translate("%(percentage)s%%"), { | return sprintf(translate("%(percentage)s%%"), { | ||||
"percentage": (attr.wins / attr.totalGamesPlayed * 100).toFixed(2) | "percentage": (attr.wins / attr.totalGamesPlayed * 100).toFixed(2) | ||||
}); | }); | ||||
} | } | ||||
function deselect() | |||||
{ | |||||
g_SelectedGameIP = ""; | |||||
g_SelectedGamePort = ""; | |||||
g_SelectedPlayer = ""; | |||||
Engine.GetGUIObjectByName("gamesBox").selected = -1; | |||||
Engine.GetGUIObjectByName("playersBox").selected = -1; | |||||
if (Engine.ConfigDB_GetValue("user", "lobby.hideprofile") == "true") | |||||
profilePanelHidden(true); | |||||
} |
It might be good to rethink how you're doing this so that you don't need all the "return true"s added elsewhere