Ticket #3244: t3244_keep_gamelist_selection_r16665.patch
File t3244_keep_gamelist_selection_r16665.patch, 2.5 KB (added by , 9 years ago) |
---|
-
binaries/data/mods/public/gui/lobby/lobby.js
2 2 var g_Name = "unknown"; 3 3 var g_GameList = {}; 4 4 var g_specialKey = Math.random(); 5 5 // This object looks like {"name":[numMessagesSinceReset, lastReset, timeBlocked]} when in use. 6 6 var g_spamMonitor = {}; 7 var g_selectedGameIP = ""; 7 8 var g_timestamp = Engine.ConfigDB_GetValue("user", "lobby.chattimestamp") == "true"; 8 9 var g_mapSizes = {}; 9 10 const g_mapTypesText = [translateWithContext("map", "Skirmish"), translateWithContext("map", "Random"), translate("Scenario")]; 10 11 const g_mapTypes = ["skirmish", "random", "scenario"]; 11 12 var g_userRating = ""; // Rating of user, defaults to Unrated … … 356 357 */ 357 358 function updateGameList() 358 359 { 359 360 var gamesBox = Engine.GetGUIObjectByName("gamesBox"); 360 361 var gameList = Engine.GetGameList(); 362 if (gamesBox.selected > -1) 363 g_selectedGameIP = g_GameList[gamesBox.selected].ip; 364 361 365 // Store the game whole game list data so that we can access it later 362 366 // to update the game info panel. 363 367 g_GameList = gameList; 364 368 365 369 // Sort the list of games to that games 'waiting' are displayed at the top, followed by 'init', followed by 'running'. … … 385 389 var list_mapType = []; 386 390 var list_nPlayers = []; 387 391 var list = []; 388 392 var list_data = []; 389 393 394 var selectedIndex = -1; 390 395 var c = 0; 391 396 for each (var g in gameList) 392 397 { 393 398 if(!filterGame(g)) 394 399 { … … 400 405 name = '[color="255 127 0"]' + name + '[/color]'; 401 406 else 402 407 name = '[color="255 0 0"]' + name + '[/color]'; 403 408 list_name.push(name); 404 409 list_ip.push(g.ip); 410 if (g.ip == g_selectedGameIP) 411 selectedIndex = list_ip.length - 1; 412 405 413 list_mapName.push(translate(g.niceMapName)); 406 414 list_mapSize.push(translatedMapSize(g.mapSize)); 407 415 let idx = g_mapTypes.indexOf(g.mapType); 408 416 list_mapType.push(idx != -1 ? g_mapTypesText[idx] : ""); 409 417 list_nPlayers.push(g.nbp + "/" +g.tnbp); … … 419 427 gamesBox.list_mapType = list_mapType; 420 428 gamesBox.list_nPlayers = list_nPlayers; 421 429 gamesBox.list = list; 422 430 gamesBox.list_data = list_data; 423 431 424 if (gamesBox.selected >= gamesBox.list_name.length)425 gamesBox.selected = -1;426 432 // Select previously selected game 433 gamesBox.selected = selectedIndex; 434 427 435 // Update info box about the game currently selected 428 436 updateGameSelection(); 429 437 } 430 438 431 439 /**