Ticket #3244: t3244_keep_gamelist_selection_a18.patch
File t3244_keep_gamelist_selection_a18.patch, 2.3 KB (added by , 9 years ago) |
---|
-
lobby.js
old new 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 … … 355 356 */ 356 357 function updateGameList() 357 358 { 358 359 var gamesBox = Engine.GetGUIObjectByName("gamesBox"); 359 360 var gameList = Engine.GetGameList(); 361 if (gamesBox.selected > -1) 362 g_selectedGameIP = g_GameList[gamesBox.selected].ip; 363 360 364 // Store the game whole game list data so that we can access it later 361 365 // to update the game info panel. 362 366 g_GameList = gameList; 363 367 364 368 // Sort the list of games to that games 'waiting' are displayed at the top, followed by 'init', followed by 'running'. … … 384 388 var list_mapType = []; 385 389 var list_nPlayers = []; 386 390 var list = []; 387 391 var list_data = []; 388 392 393 var selectedIndex = -1; 389 394 var c = 0; 390 395 for each (var g in gameList) 391 396 { 392 397 if(!filterGame(g)) 393 398 { … … 399 404 name = '[color="255 127 0"]' + g.name + '[/color]'; 400 405 else 401 406 name = '[color="255 0 0"]' + g.name + '[/color]'; 402 407 list_name.push(name); 403 408 list_ip.push(g.ip); 409 if (g.ip == g_selectedGameIP) 410 selectedIndex = list_ip.length - 1; 404 411 list_mapName.push(translate(g.niceMapName)); 405 412 list_mapSize.push(translatedMapSize(g.mapSize)); 406 413 let idx = g_mapTypes.indexOf(g.mapType); 407 414 list_mapType.push(idx != -1 ? g_mapTypesText[idx] : ""); 408 415 list_nPlayers.push(g.nbp + "/" +g.tnbp); … … 418 425 gamesBox.list_mapType = list_mapType; 419 426 gamesBox.list_nPlayers = list_nPlayers; 420 427 gamesBox.list = list; 421 428 gamesBox.list_data = list_data; 422 429 423 if (gamesBox.selected >= gamesBox.list_name.length)424 gamesBox.selected = -1;425 430 // Select previously selected game 431 gamesBox.selected = selectedIndex; 432 426 433 // Update info box about the game currently selected 427 434 updateGameSelection(); 428 435 } 429 436 430 437 /**