Ticket #3244: t3244_keep_gamelist_selection_r16665.patch

File t3244_keep_gamelist_selection_r16665.patch, 2.5 KB (added by elexis, 9 years ago)

Fixes the first part of this ticket. You can test it briefly in svn by hosting a match with only 1 player slot, another client in the lobby and then cliking the show-full-games trigger.

  • binaries/data/mods/public/gui/lobby/lobby.js

     
    22var g_Name = "unknown";
    33var g_GameList = {};
    44var g_specialKey = Math.random();
    55// This object looks like {"name":[numMessagesSinceReset, lastReset, timeBlocked]} when in use.
    66var g_spamMonitor = {};
     7var g_selectedGameIP = "";
    78var g_timestamp = Engine.ConfigDB_GetValue("user", "lobby.chattimestamp") == "true";
    89var g_mapSizes = {};
    910const g_mapTypesText = [translateWithContext("map", "Skirmish"), translateWithContext("map", "Random"), translate("Scenario")];
    1011const g_mapTypes = ["skirmish", "random", "scenario"];
    1112var g_userRating = ""; // Rating of user, defaults to Unrated
     
    356357 */
    357358function updateGameList()
    358359{
    359360    var gamesBox = Engine.GetGUIObjectByName("gamesBox");
    360361    var gameList = Engine.GetGameList();
     362    if (gamesBox.selected > -1)
     363        g_selectedGameIP = g_GameList[gamesBox.selected].ip;
     364   
    361365    // Store the game whole game list data so that we can access it later
    362366    // to update the game info panel.
    363367    g_GameList = gameList;
    364368
    365369    // Sort the list of games to that games 'waiting' are displayed at the top, followed by 'init', followed by 'running'.
     
    385389    var list_mapType = [];
    386390    var list_nPlayers = [];
    387391    var list = [];
    388392    var list_data = [];
    389393
     394    var selectedIndex = -1;
    390395    var c = 0;
    391396    for each (var g in gameList)
    392397    {
    393398        if(!filterGame(g))
    394399        {
     
    400405                name = '[color="255 127 0"]' + name + '[/color]';
    401406            else
    402407                name = '[color="255 0 0"]' + name + '[/color]';
    403408            list_name.push(name);
    404409            list_ip.push(g.ip);
     410            if (g.ip == g_selectedGameIP)
     411                selectedIndex = list_ip.length - 1;
     412
    405413            list_mapName.push(translate(g.niceMapName));
    406414            list_mapSize.push(translatedMapSize(g.mapSize));
    407415            let idx = g_mapTypes.indexOf(g.mapType);
    408416            list_mapType.push(idx != -1 ? g_mapTypesText[idx] : "");
    409417            list_nPlayers.push(g.nbp + "/" +g.tnbp);
     
    419427    gamesBox.list_mapType = list_mapType;
    420428    gamesBox.list_nPlayers = list_nPlayers;
    421429    gamesBox.list = list;
    422430    gamesBox.list_data = list_data;
    423431
    424     if (gamesBox.selected >= gamesBox.list_name.length)
    425         gamesBox.selected = -1;
    426 
     432    // Select previously selected game
     433    gamesBox.selected = selectedIndex;
     434   
    427435    // Update info box about the game currently selected
    428436    updateGameSelection();
    429437}
    430438
    431439/**