Ticket #3209: t3209_keep_victory_condition.patch

File t3209_keep_victory_condition.patch, 3.8 KB (added by elexis, 9 years ago)
  • binaries/data/mods/public/gui/gamesetup/gamesetup.js

     
    387387        Engine.GetGUIObjectByName("mapSelection").focus();
    388388    }
    389389
    390390    if (g_IsController)
    391391    {
    392         loadGameAttributes();
     392        loadPersistMatchSettings();
    393393        // Sync g_GameAttributes to everyone.
    394394        if (g_IsInGuiUpdate)
    395395            warn("initMain() called while in GUI update");
    396396
    397397        updateGameAttributes();
     
    674674    return g_MapData[name];
    675675}
    676676
    677677const FILEPATH_MATCHSETTINGS_SP = "config/matchsettings.json";
    678678const FILEPATH_MATCHSETTINGS_MP = "config/matchsettings.mp.json";
    679 function loadGameAttributes()
     679function loadPersistMatchSettings()
    680680{
    681681    if (Engine.ConfigDB_GetValue("user", "persistmatchsettings") != "true")
    682682        return;
    683683
    684684    var settingsFile = g_IsNetworked ? FILEPATH_MATCHSETTINGS_MP : FILEPATH_MATCHSETTINGS_SP;
     
    718718        {
    719719            if (civListCodes.indexOf(playerData[i].Civ) < 0)
    720720                playerData[i].Civ = "random";
    721721        }
    722722    }
    723 
    724723    // Refresh probably obsoleted/incomplete map data.
    725724    var newMapData = loadMapData(mapName);
    726725    if (newMapData && newMapData.settings)
    727726    {
    728727        for (var prop in newMapData.settings)
     
    742741    initMapNameList();
    743742
    744743    var mapSelectionBox = Engine.GetGUIObjectByName("mapSelection");
    745744    mapSelectionBox.selected = mapSelectionBox.list_data.indexOf(mapName);
    746745
     746    if (attrs.gameSpeed)
     747    {
     748        var gameSpeedBox = Engine.GetGUIObjectByName("gameSpeed");
     749        gameSpeedBox.selected = g_GameSpeeds.speeds.indexOf(attrs.gameSpeed);
     750    }
     751    if (mapSettings.GameType)
     752    {
     753        var victoryConditions = Engine.GetGUIObjectByName("victoryCondition");
     754        var victories = getVictoryConditions();
     755        victoryConditions.selected = victories.data.indexOf(mapSettings.GameType);
     756    }
    747757    if (mapSettings.PopulationCap)
    748758    {
    749759        var populationCapBox = Engine.GetGUIObjectByName("populationCap");
    750760        populationCapBox.selected = populationCapBox.list_data.indexOf(mapSettings.PopulationCap);
    751761    }
    752762    if (mapSettings.StartingResources)
    753763    {
    754764        var startingResourcesBox = Engine.GetGUIObjectByName("startingResources");
    755765        startingResourcesBox.selected = startingResourcesBox.list_data.indexOf(mapSettings.StartingResources);
    756766    }
    757 
    758767    if (mapSettings.Ceasefire)
    759768    {
    760769        var ceasefireBox = Engine.GetGUIObjectByName("ceasefire");
    761770        ceasefireBox.selected = ceasefireBox.list_data.indexOf(mapSettings.Ceasefire);
    762771    }
    763 
    764     if (attrs.gameSpeed)
    765     {
    766         var gameSpeedBox = Engine.GetGUIObjectByName("gameSpeed");
    767         gameSpeedBox.selected = g_GameSpeeds.speeds.indexOf(attrs.gameSpeed);
    768     }
    769 
    770772    if (!Engine.HasXmppClient())
    771773    {
    772774        g_GameAttributes.settings.RatingEnabled = false;
    773775        Engine.SetRankedGame(false);
    774776        Engine.GetGUIObjectByName("enableRating").checked = false;
    775777        Engine.GetGUIObjectByName("enableCheats").enabled = true;
    776778        Engine.GetGUIObjectByName("lockTeams").enabled = true;
    777779    }
    778 
    779780    g_IsInGuiUpdate = false;
    780781
    781782    onGameAttributesChange();
    782783}
    783784
     
    975976            g_GameAttributes.settings[prop] = undefined;
    976977
    977978    var mapData = loadMapData(name);
    978979    var mapSettings = (mapData && mapData.settings ? deepcopy(mapData.settings) : {});
    979980
    980     // Reset victory conditions
    981     var victories = getVictoryConditions();
    982     var victoryIdx = (mapSettings.GameType !== undefined && victories.data.indexOf(mapSettings.GameType) != -1 ? victories.data.indexOf(mapSettings.GameType) : VICTORY_DEFAULTIDX);
    983     g_GameAttributes.settings.GameType = victories.data[victoryIdx];
    984     g_GameAttributes.settings.VictoryScripts = victories.scripts[victoryIdx];
    985 
    986981    // Copy any new settings
    987982    g_GameAttributes.map = name;
    988983    g_GameAttributes.script = mapSettings.Script;
    989984    if (g_GameAttributes.map !== "random")
    990985        for (var prop in mapSettings)