Ticket #3987: random_cultures_option.patch

File random_cultures_option.patch, 4.2 KB (added by Sandarac, 8 years ago)

Adds check box in More Options

  • gamesetup.js

     
    353353        "optionExploreMap",
    354354        "optionDisableTreasures",
    355355        "optionLockTeams",
     356        "optionRandomCivs",
    356357        "optionCheats",
    357358        "optionRating",
    358359        "hideMoreOptions"
     
    508509        "ExploreMap": "exploreMap",
    509510        "DisableTreasures": "disableTreasures",
    510511        "LockTeams": "lockTeams",
     512        "RandomCivs" : "randomCivs",
    511513        "CheatsEnabled": "enableCheats"
    512514    };
    513515
     
    12461248    // Get a unique array of selectable cultures
    12471249    let cultures = Object.keys(g_CivData).filter(civ => g_CivData[civ].SelectableInGameSetup).map(civ => g_CivData[civ].Culture);
    12481250    cultures = cultures.filter((culture, index) => cultures.indexOf(culture) === index);
     1251    let civs = Object.keys(g_CivData).filter(civ => g_CivData[civ].SelectableInGameSetup)
    12491252
    12501253    // Determine random civs and botnames
    12511254    for (let i in g_GameAttributes.settings.PlayerData)
     
    12541257        let chosenCiv = g_GameAttributes.settings.PlayerData[i].Civ || "random";
    12551258        if (chosenCiv == "random")
    12561259        {
    1257             let culture = cultures[Math.floor(Math.random() * cultures.length)];
    1258             let civs = Object.keys(g_CivData).filter(civ => g_CivData[civ].Culture == culture);
    1259             chosenCiv = civs[Math.floor(Math.random() * civs.length)];
     1260            if (g_GameAttributes.settings.RandomCivs)
     1261            {
     1262                let culture = cultures[Math.floor(Math.random() * cultures.length)];
     1263                let civs = Object.keys(g_CivData).filter(civ => g_CivData[civ].Culture == culture);
     1264                chosenCiv = civs[Math.floor(Math.random() * civs.length)];
     1265            }
     1266            else
     1267            {
     1268                chosenCiv = civs[Math.floor(Math.random() * civs.length)];
     1269            }
    12601270        }
    12611271        g_GameAttributes.settings.PlayerData[i].Civ = chosenCiv;
    12621272
     
    13711381    setGUIBoolean("exploreMap", "exploreMapText", !!mapSettings.ExploreMap);
    13721382    setGUIBoolean("revealMap", "revealMapText", !!mapSettings.RevealMap);
    13731383    setGUIBoolean("lockTeams", "lockTeamsText", !!mapSettings.LockTeams);
     1384    setGUIBoolean("randomCivs", "randomCivsText", !!mapSettings.RandomCivs);
    13741385    setGUIBoolean("enableRating", "enableRatingText", !!mapSettings.RatingEnabled);
    13751386
    13761387    Engine.GetGUIObjectByName("optionWonderDuration").hidden =
     
    13931404
    13941405    for (let ctrl of ["victoryCondition", "wonderDuration", "populationCap",
    13951406                      "startingResources", "ceasefire", "revealMap",
    1396                       "exploreMap", "disableTreasures", "lockTeams"])
     1407                      "exploreMap", "disableTreasures", "lockTeams", "randomCivs"])
    13971408        hideControl(ctrl, ctrl + "Text", notScenario);
    13981409
    13991410    for (let i = 0; i < g_MaxPlayers; ++i)
  • gamesetup.xml

     
    376376                    </object>
    377377                </object>
    378378
    379                 <object name="optionCheats" size="14 338 94% 366" hidden="true">
     379                <object name="optionRandomCivs" size="14 338 94% 366">
    380380                    <object size="0 0 40% 28" type="text" style="ModernRightLabelText">
     381                        <translatableAttribute id="caption">Random Cultures:</translatableAttribute>
     382                    </object>
     383                    <object name="randomCivsText" size="40% 0 100% 28" type="text" style="ModernLeftLabelText"/>
     384                    <object name="randomCivs" size="40%+10 5 40%+30 100%-5" type="checkbox" style="ModernTickBox" hidden="true" tooltip_style="onscreenToolTip">
     385                        <translatableAttribute id="tooltip">Toggle the selection of random civilizations by culture.</translatableAttribute>
     386                    </object>
     387                </object>
     388               
     389                <object name="optionCheats" size="14 368 94% 396" hidden="true">
     390                    <object size="0 0 40% 28" type="text" style="ModernRightLabelText">
    381391                        <translatableAttribute id="caption">Cheats:</translatableAttribute>
    382392                    </object>
    383393                    <object name="enableCheatsText" size="40% 0 100% 28" type="text" style="ModernLeftLabelText"/>
     
    386396                    </object>
    387397                </object>
    388398
    389                 <object name="optionRating" size="14 368 94% 396" hidden="true">
     399                <object name="optionRating" size="14 398 94% 426" hidden="true">
    390400                    <object size="0 0 40% 28" hidden="false" type="text" style="ModernRightLabelText">
    391401                        <translatableAttribute id="caption">Rated Game:</translatableAttribute>
    392402                    </object>