Ticket #3355: t3355_move_gamesetup_strings_v2.1.patch

File t3355_move_gamesetup_strings_v2.1.patch, 88.6 KB (added by elexis, 9 years ago)

Fixes wrong TranslatedKeys entry in the GameTypes json files.

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

     
    33
    44function init(settings)
    55{
    66    g_PlayerSlot = settings.playerSlot;
    77
    8     translateObjectKeys(settings.ais, ["name", "description"]);
    98    g_AIs = [
    10         {id: "", data: {name: translateWithContext("ai", "None"), description: translate("AI will be disabled for this player.")}}
     9        { "id": "",
     10            "data": {
     11                "name": translateWithContext("ai", "None"),
     12                "description": translate("AI will be disabled for this player.")
     13            }
     14        }
    1115    ].concat(settings.ais);
    1216
    1317    var aiSelection = Engine.GetGUIObjectByName("aiSelection");
    14     aiSelection.list = [ translate(ai.data.name) for each (ai in g_AIs) ];
    15 
    16     var selected = 0;
    17     for (var i = 0; i < g_AIs.length; ++i)
    18     {
    19         if (g_AIs[i].id == settings.id)
    20         {
    21             selected = i;
    22             break;
    23         }
    24     }
    25     aiSelection.selected = selected;
     18    aiSelection.list = g_AIs.map(ai => translate(ai.data.name));
     19    aiSelection.selected = g_AIs.findIndex(ai => ai.id == settings.id);
    2620
    2721    var aiDiff = Engine.GetGUIObjectByName("aiDifficulty");
    28     // Translation: AI difficulty level.
    29     aiDiff.list = [translateWithContext("aiDiff", "Sandbox"), translateWithContext("aiDiff", "Very Easy"), translateWithContext("aiDiff", "Easy"), translateWithContext("aiDiff", "Medium"), translateWithContext("aiDiff", "Hard"), translateWithContext("aiDiff", "Very Hard")];
     22    aiDiff.list = settings.difficulties.Title;
    3023    aiDiff.selected = settings.difficulty;
    3124}
    3225
    3326function selectAI(idx)
    3427{
    35     var id = g_AIs[idx].id;
    36     var name = g_AIs[idx].data.name;
    37     var description = g_AIs[idx].data.description;
    38 
    39     Engine.GetGUIObjectByName("aiDescription").caption = description;
     28    Engine.GetGUIObjectByName("aiDescription").caption = g_AIs[idx].data.description;
    4029}
    4130
    4231function returnAI()
    4332{
    44     var aiSelection = Engine.GetGUIObjectByName("aiSelection");
    45     var idx = aiSelection.selected;
    46     var id = g_AIs[idx].id;
    47     var name = g_AIs[idx].data.name;
    48 
     33    var idx = Engine.GetGUIObjectByName("aiSelection").selected;
    4934    var difficulty = Engine.GetGUIObjectByName("aiDifficulty").selected;
    50    
     35
    5136    // Pop the page before calling the callback, so the callback runs
    5237    // in the parent GUI page's context
    53     Engine.PopGuiPageCB({"id": id, "name": name, "difficulty" : difficulty, "playerSlot" : g_PlayerSlot });
     38    Engine.PopGuiPageCB({
     39        "id": g_AIs[idx].id,
     40        "name": g_sAIs[idx].data.name,
     41        "difficulty": difficulty,
     42        "playerSlot": g_PlayerSlot
     43    });
    5444}
  • binaries/data/mods/public/gui/common/functions_utility.js

     
    8383    return text.substr(0, 255).replace(/\\/g, "\\\\").replace(/\[/g, "\\[");
    8484}
    8585
    8686// ====================================================================
    8787
    88 // Load default player data, for when it's not otherwise specified
    89 function initPlayerDefaults()
    90 {
    91     var data = Engine.ReadJSONFile("simulation/data/player_defaults.json");
    92     if (!data || !data.PlayerData)
    93     {
    94         error("Failed to parse player defaults in player_defaults.json (check for valid JSON data)");
    95         return [];
    96     }
    97 
    98     return data.PlayerData;
    99 }
    100 
    101 // ====================================================================
    10288
    103 // Load map size data
    104 function initMapSizes()
     89// Loads the translated description and filename of the preview image of the map (or a placeholder for random map).
     90function getMapDescriptionAndPreview(mapType, mapName)
    10591{
    106     var sizes = {
    107         "shortNames":[],
    108         "names":[],
    109         "tiles": [],
    110         "default": 0
    111     };
    112 
    113     var data = Engine.ReadJSONFile("simulation/data/map_sizes.json");
    114     if (!data || !data.Sizes)
    115     {
    116         error("Failed to parse map sizes in map_sizes.json (check for valid JSON data)");
    117         return sizes;
    118     }
    119 
    120     translateObjectKeys(data, ["Name", "LongName"]);
    121     for (var i = 0; i < data.Sizes.length; ++i)
    122     {
    123         sizes.shortNames.push(data.Sizes[i].Name);
    124         sizes.names.push(data.Sizes[i].LongName);
    125         sizes.tiles.push(data.Sizes[i].Tiles);
    126 
    127         if (data.Sizes[i].Default)
    128             sizes["default"] = i;
    129     }
    130 
    131     return sizes;
    132 }
    133 
    134 // ====================================================================
     92    let mapData;
     93    if (mapType == "random" && mapName == "random")
     94        mapData = { "settings": { "Description": translate("A randomly selected map.") } };
     95    else if (mapType == "random" && Engine.FileExists(mapName + ".json"))
     96        mapData = Engine.ReadJSONFile(mapName + ".json");
     97    else if (Engine.FileExists(mapName + ".xml"))
     98        mapData = Engine.LoadMapSettings(mapName + ".xml");
     99    else
     100        warn(sprintf("Map '%(mapName)s' not found locally.", { "mapName": mapName }));
    135101
    136 // Load game speed data
    137 function initGameSpeeds()
    138 {
    139     var gameSpeeds = {
    140         "names": [],
    141         "speeds": [],
    142         "default": 0
     102    return {
     103        "description": mapData && mapData.settings.Description ?
     104            translate(mapData.settings.Description) :
     105            translate("Sorry, no description available."),
     106
     107        "preview": mapData && mapData.settings.Preview ?
     108            mapData.settings.Preview :
     109            "nopreview.png"
    143110    };
    144 
    145     var data = Engine.ReadJSONFile("simulation/data/game_speeds.json");
    146     if (!data || !data.Speeds)
    147     {
    148         error("Failed to parse game speeds in game_speeds.json (check for valid JSON data)");
    149         return gameSpeeds;
    150     }
    151 
    152     translateObjectKeys(data, ["Name"]);
    153     for (var i = 0; i < data.Speeds.length; ++i)
    154     {
    155         gameSpeeds.names.push(data.Speeds[i].Name);
    156         gameSpeeds.speeds.push(data.Speeds[i].Speed);
    157 
    158         if (data.Speeds[i].Default)
    159             gameSpeeds["default"] = i;
    160     }
    161 
    162     return gameSpeeds;
    163111}
    164112
    165 
    166113// ====================================================================
    167114
    168115// Convert integer color values to string (for use in GUI objects)
    169116function rgbToGuiColor(color, alpha)
    170117{
     
    258205
    259206    for (var word of autoCompleteList)
    260207    {
    261208        if (word.toLowerCase().indexOf(lastWord.toLowerCase()) != 0)
    262209            continue;
    263        
     210
    264211        text = wordSplit.join(" ")
    265212        if (text.length > 0)
    266213            text += " ";
    267214
    268215        text += word;
  • binaries/data/mods/public/gui/common/settings.js

     
     1// Used by lobby, gamesetup, session, and replay GUI
     2const g_Settings = loadAvailableSettings();
     3
     4function loadAvailableSettings()
     5{
     6    const rootDir = "simulation/data/settings/";
     7    const gameTypeDir = rootDir + "GameTypes/";
     8
     9    // Load Player Limits
     10    let settings = Engine.ReadJSONFile(rootDir + "PlayerLimit.json");
     11    if (!settings)
     12        return false;
     13
     14    // Load Game Types
     15    settings.GameTypes = [];
     16    for (let file of Engine.BuildDirEntList(gameTypeDir, "*.json", false))
     17    {
     18        let gameType = file.substr(gameTypeDir.length).replace(".json", "");
     19        gameType = loadAvailableSettingsFile(gameType, file)
     20
     21        if (!gameType)
     22            return false;
     23
     24        settings.GameTypes.push(gameType);
     25    }
     26
     27    // Load even more settings
     28    const settingNames = ["AIDifficulties", "Ceasefire", "GameSpeeds", "MapTypes", "MapSizes",
     29                          "PlayerDefaults", "PopulationCapacity", "StartingResources"];
     30    for (let settingName of settingNames)
     31    {
     32        settings[settingName] = loadAvailableSettingsFile(settingName, rootDir + settingName + ".json");
     33        if (!settings[settingName])
     34            return false;
     35    }
     36
     37    return settings;
     38}
     39
     40function loadAvailableSettingsFile(settingName, filename)
     41{
     42    let json = Engine.ReadJSONFile(filename);
     43
     44    if (!json || !json[settingName])
     45    {
     46        error("Couldn't load " + settingName + " settings!");
     47        return false;
     48    }
     49
     50    if (json.TranslatedKeys)
     51        translateObjectKeys(json, json.TranslatedKeys);
     52
     53    return json[settingName];
     54}
     55
     56function initAIDescription()
     57{
     58    let ais = Engine.GetAIs();
     59    translateObjectKeys(ais, ["name", "description"]);
     60    // Sort ais by displayed name
     61    ais.sort((a, b) => a.data.name < b.data.name ? -1 : b.data.name < a.data.name ? +1 : 0);
     62    return ais;
     63}
     64
     65// Shows a message box and calls a function if the setting files couldn't be
     66// parsed
     67function validSettings(callback)
     68{
     69    if (!g_Settings)
     70        messageBox(400, 200, translate("Can't load game settings!"), translate("ERROR!"), 0, [translate("OK")], [callback]);
     71
     72    return g_Settings;
     73}
     74
     75/*
     76 * Switches propertyname and value index and extracts default value to easily
     77 * copy settings to dropdownlists. Requires g_Settings.
     78 */
     79function prepareForDropdown(settingsName)
     80{
     81    let settings = {};
     82    let settingValues = g_Settings[settingsName];
     83    for (let index in settingValues)
     84    {
     85        for (let property in settingValues[index])
     86        {
     87            if (property == "Default")
     88                continue;
     89
     90            if (index == 0)
     91                settings[property] = [];
     92
     93            // Switch property and index
     94            settings[property][index] = settingValues[index][property];
     95        }
     96
     97        // Copy default value
     98        if (settingValues[index].Default)
     99            settings.default = +index;
     100    }
     101    return settings;
     102}
     103
     104//Returns the translation of the given AI name (like "petra"). Requires g_AIs.
     105function translateAIName(aiName)
     106{
     107    let description = g_AIs.find(ai => ai.id == aiName);
     108    return description ? translate(description.data.name) : translateWithContext("AI name", "Unknown");
     109}
     110
     111// Returns the translation of the given AI difficulty. Requires g_Settings.
     112function translateAIDifficulty(index)
     113{
     114    let difficulty = g_Settings.AIDifficulties[index];
     115    return difficulty ? difficulty.Title : translateWithContext("AI difficulty", "Unknown");
     116}
     117
     118// Returns the translation of the given map type. Requires g_Settings.
     119function translateCeasefire(duration)
     120{
     121    let ceasefire = g_Settings.Ceasefire.find(c => c.Duration == duration);
     122    return ceasefire ? ceasefire.Title : translateWithContext("ceasefire duration", "Unknown");
     123}
     124
     125// Returns the translation of the given map type. Requires g_Settings.
     126function translateGameType(gameType)
     127{
     128    let type = g_Settings.GameTypes.find(t => t.Name == gameType);
     129    return type ? type.Title : translateWithContext("game type", "Unknown");
     130}
     131
     132// Returns the translation of the given map type. Requires g_Settings.
     133function translateMapType(mapType)
     134{
     135    let type = g_Settings.MapTypes.find(t => t.Name == mapType);
     136    return type ? type.Title : translateWithContext("map type", "Unknown");
     137}
     138
     139// Returns translated map size for a given a numeric size. Requires g_Settings.
     140function translateMapSize(tiles)
     141{
     142    let size = g_Settings.MapSizes.find(s => s.Tiles == tiles);
     143    return size ? size.Name : translateWithContext("map size", "Default");
     144}
     145
     146// Returns the translation for a given numeric value. Requires g_Settings.
     147function translatePopulationCapacity(population)
     148{
     149    let popCap = g_Settings.PopulationCapacity.find(p => p.Population == population);
     150    return popCap ? popCap.Title : translateWithContext("population capacity", "Unknown");
     151}
  • binaries/data/mods/public/gui/gamesetup/gamesetup.js

     
    1 ////////////////////////////////////////////////////////////////////////////////////////////////
    21// Constants
    32const DEFAULT_NETWORKED_MAP = "Acropolis 01";
    43const DEFAULT_OFFLINE_MAP = "Acropolis 01";
    54
    6 const VICTORY_DEFAULTIDX = 1;
    7 
    8 // TODO: Move these somewhere like simulation\data\game_types.json, Atlas needs them too
    9 // Translation: Type of victory condition.
    10 const POPULATION_CAP = ["50", "100", "150", "200", "250", "300", translate("Unlimited")];
    11 const POPULATION_CAP_DATA = [50, 100, 150, 200, 250, 300, 10000];
    12 const POPULATION_CAP_DEFAULTIDX = 5;
    13 // Translation: Amount of starting resources.
    14 const STARTING_RESOURCES = [translateWithContext("startingResources", "Very Low"), translateWithContext("startingResources", "Low"), translateWithContext("startingResources", "Medium"), translateWithContext("startingResources", "High"), translateWithContext("startingResources", "Very High"), translateWithContext("startingResources", "Deathmatch")];
    15 const STARTING_RESOURCES_DATA = [100, 300, 500, 1000, 3000, 50000];
    16 const STARTING_RESOURCES_DEFAULTIDX = 1;
    17 // Translation: Ceasefire.
    18 const CEASEFIRE = [translateWithContext("ceasefire", "No ceasefire"), translateWithContext("ceasefire", "5 minutes"), translateWithContext("ceasefire", "10 minutes"), translateWithContext("ceasefire", "15 minutes"), translateWithContext("ceasefire", "20 minutes"), translateWithContext("ceasefire", "30 minutes"), translateWithContext("ceasefire", "45 minutes"), translateWithContext("ceasefire", "60 minutes")];
    19 const CEASEFIRE_DATA = [0, 5, 10, 15, 20, 30, 45, 60];
    20 const CEASEFIRE_DEFAULTIDX = 0;
    21 // Max number of players for any map
    22 const MAX_PLAYERS = 8;
    23 
    24 ////////////////////////////////////////////////////////////////////////////////////////////////
     5// Contains settings transformed for the dropdown lists
     6var g_AIDiffs = {};
     7var g_Ceasefire = {};
     8var g_GameSpeeds = {};
     9var g_GameTypes = {};
     10var g_MapSizes = {};
     11var g_MapTypes = {};
     12var g_PlayerDefaults = [];
     13var g_PopulationCapacity = {};
     14var g_StartingResources = {};
    2515
    2616// Is this is a networked game, or offline
    2717var g_IsNetworked;
    2818
    2919// Is this user in control of game settings (i.e. is a network server, or offline player)
     
    5040var g_GameStarted = false;
    5141
    5242var g_PlayerAssignments = {};
    5343
    5444// Default game setup attributes
    55 var g_DefaultPlayerData = [];
    5645var g_GameAttributes = {
    5746    settings: {}
    5847};
    5948
    60 var g_GameSpeeds = {};
    61 var g_MapSizes = {};
    62 
    63 var g_AIs = [];
    64 
    6549var g_ChatMessages = [];
    6650
    6751// Data caches
    6852var g_MapData = {};
    6953var g_CivData = {};
     
    7660// To prevent the display locking up while we load the map metadata,
    7761// we'll start with a 'loading' message and switch to the main screen in the
    7862// tick handler
    7963var g_LoadingState = 0; // 0 = not started, 1 = loading, 2 = loaded
    8064
    81 // Filled by scripts in victory_conditions/
    82 var g_VictoryConditions = {};
    83 
    8465////////////////////////////////////////////////////////////////////////////////////////////////
    8566
    8667function init(attribs)
    8768{
    8869    switch (attribs.type)
     
    11596}
    11697
    11798// Called after the map data is loaded and cached
    11899function initMain()
    119100{
    120     // Load AI list
    121     g_AIs = Engine.GetAIs();
    122 
    123     // Sort AIs by displayed name
    124     g_AIs.sort(function (a, b) {
    125         return a.data.name < b.data.name ? -1 : b.data.name < a.data.name ? +1 : 0;
    126     });
    127 
    128     // Get default player data - remove gaia
    129     g_DefaultPlayerData = initPlayerDefaults();
    130     g_DefaultPlayerData.shift();
    131     for (var i = 0; i < g_DefaultPlayerData.length; ++i)
    132         g_DefaultPlayerData[i].Civ = "random";
     101    if (!validSettings(cancelAndReturn))
     102        return;
    133103
    134     g_GameSpeeds = initGameSpeeds();
    135     g_MapSizes = initMapSizes();
     104    // Transform setting arrays for usage in dropdown lists
     105    g_AIDiffs = prepareForDropdown("AIDifficulties");
     106    g_Ceasefire = prepareForDropdown("Ceasefire");
     107    g_GameSpeeds = prepareForDropdown("GameSpeeds");
     108    g_GameTypes = prepareForDropdown("GameTypes");
     109    g_MapSizes = prepareForDropdown("MapSizes");
     110    g_MapTypes = prepareForDropdown("MapTypes");
     111    g_PopulationCapacity = prepareForDropdown("PopulationCapacity");
     112    g_StartingResources = prepareForDropdown("StartingResources");
     113
     114    // Modify player defaults for later usage
     115    g_PlayerDefaults = g_Settings.PlayerDefaults.map(player => { player.Civ = "random"; return player; });
     116    g_PlayerDefaults.shift()
    136117
    137118    // Init civs
    138119    initCivNameList();
    139120
    140121    // Init map types
    141122    var mapTypes = Engine.GetGUIObjectByName("mapTypeSelection");
    142     mapTypes.list = [translateWithContext("map", "Skirmish"), translateWithContext("map", "Random"), translate("Scenario")];
    143     mapTypes.list_data = ["skirmish","random","scenario"];
     123    mapTypes.list = g_MapTypes.Title;
     124    mapTypes.list_data = g_MapTypes.Name;
    144125
    145126    // Setup map filters - will appear in order they are added
    146127    addFilter("default", translate("Default"), function(settings) { return settings && (settings.Keywords === undefined || !keywordTestOR(settings.Keywords, ["naval", "demo", "hidden"])); });
    147128    addFilter("naval", translate("Naval Maps"), function(settings) { return settings && settings.Keywords !== undefined && keywordTestAND(settings.Keywords, ["naval"]); });
    148129    addFilter("demo", translate("Demo Maps"), function(settings) { return settings && settings.Keywords !== undefined && keywordTestAND(settings.Keywords, ["demo"]); });
     
    165146        g_GameAttributes.matchID = Engine.GetMatchID();
    166147
    167148        initMapNameList();
    168149
    169150        var numPlayersSelection = Engine.GetGUIObjectByName("numPlayersSelection");
    170         var players = [];
    171         for (var i = 1; i <= MAX_PLAYERS; ++i)
    172             players.push(i);
    173         numPlayersSelection.list = players;
    174         numPlayersSelection.list_data = players;
    175         numPlayersSelection.selected = MAX_PLAYERS - 1;
     151        let playersArray = Array(g_Settings.MaxPlayers).fill(0).map((value, index) => index + 1);
     152        numPlayersSelection.list = playersArray;
     153        numPlayersSelection.list_data = playersArray;
     154        numPlayersSelection.selected = g_Settings.MaxPlayers - 1;
    176155
    177156        var gameSpeed = Engine.GetGUIObjectByName("gameSpeed");
    178157        gameSpeed.hidden = false;
    179158        Engine.GetGUIObjectByName("gameSpeedText").hidden = true;
    180         gameSpeed.list = g_GameSpeeds.names;
    181         gameSpeed.list_data = g_GameSpeeds.speeds;
     159        gameSpeed.list = g_GameSpeeds.Title;
     160        gameSpeed.list_data = g_GameSpeeds.Speed;
    182161        gameSpeed.onSelectionChange = function() {
    183162            if (this.selected != -1)
    184                 g_GameAttributes.gameSpeed = g_GameSpeeds.speeds[this.selected];
     163                g_GameAttributes.gameSpeed = g_GameSpeeds.Speed[this.selected];
    185164
    186165            updateGameAttributes();
    187166        }
    188         gameSpeed.selected = g_GameSpeeds["default"];
     167        gameSpeed.selected = g_GameSpeeds.default;
    189168
    190169        var populationCaps = Engine.GetGUIObjectByName("populationCap");
    191         populationCaps.list = POPULATION_CAP;
    192         populationCaps.list_data = POPULATION_CAP_DATA;
    193         populationCaps.selected = POPULATION_CAP_DEFAULTIDX;
     170        populationCaps.list = g_PopulationCapacity.Title;
     171        populationCaps.list_data = g_PopulationCapacity.Population;
     172        populationCaps.selected = g_PopulationCapacity.default;
    194173        populationCaps.onSelectionChange = function() {
    195174            if (this.selected != -1)
    196                 g_GameAttributes.settings.PopulationCap = POPULATION_CAP_DATA[this.selected];
     175                g_GameAttributes.settings.PopulationCap = g_PopulationCapacity.Population[this.selected];
    197176
    198177            updateGameAttributes();
    199178        }
    200179
    201180        var startingResourcesL = Engine.GetGUIObjectByName("startingResources");
    202         startingResourcesL.list = STARTING_RESOURCES;
    203         startingResourcesL.list_data = STARTING_RESOURCES_DATA;
    204         startingResourcesL.selected = STARTING_RESOURCES_DEFAULTIDX;
     181        startingResourcesL.list = g_StartingResources.Title;
     182        startingResourcesL.list_data = g_StartingResources.Resources;
     183        startingResourcesL.selected = g_StartingResources.default;
    205184        startingResourcesL.onSelectionChange = function() {
    206185            if (this.selected != -1)
    207                 g_GameAttributes.settings.StartingResources = STARTING_RESOURCES_DATA[this.selected];
     186                g_GameAttributes.settings.StartingResources = g_StartingResources.Resources[this.selected];
    208187
    209188            updateGameAttributes();
    210189        }
    211190
    212191        var ceasefireL = Engine.GetGUIObjectByName("ceasefire");
    213         ceasefireL.list = CEASEFIRE;
    214         ceasefireL.list_data = CEASEFIRE_DATA;
    215         ceasefireL.selected = CEASEFIRE_DEFAULTIDX;
     192        ceasefireL.list = g_Ceasefire.Title;
     193        ceasefireL.list_data = g_Ceasefire.Duration;
     194        ceasefireL.selected = g_Ceasefire.default;
    216195        ceasefireL.onSelectionChange = function() {
    217196            if (this.selected != -1)
    218                 g_GameAttributes.settings.Ceasefire = CEASEFIRE_DATA[this.selected];
     197                g_GameAttributes.settings.Ceasefire = g_Ceasefire.Duration[this.selected];
    219198
    220199            updateGameAttributes();
    221200        }
    222201
    223202        var victoryConditions = Engine.GetGUIObjectByName("victoryCondition");
    224         var victories = getVictoryConditions();
    225         victoryConditions.list = victories.text;
    226         victoryConditions.list_data = victories.data;
     203        victoryConditions.list = g_GameTypes.Title;
     204        victoryConditions.list_data = g_GameTypes.Name;
    227205        victoryConditions.onSelectionChange = function() {
    228206            if (this.selected != -1)
    229207            {
    230                 g_GameAttributes.settings.GameType = victories.data[this.selected];
    231                 g_GameAttributes.settings.VictoryScripts = victories.scripts[this.selected];
     208                g_GameAttributes.settings.GameType = g_GameTypes.Name[this.selected];
     209                g_GameAttributes.settings.VictoryScripts = g_GameTypes.Scripts[this.selected];
    232210            }
    233211
    234212            updateGameAttributes();
    235213        };
    236         victoryConditions.selected = VICTORY_DEFAULTIDX;
     214        victoryConditions.selected = g_GameTypes.default;
    237215
    238216        var mapSize = Engine.GetGUIObjectByName("mapSize");
    239         mapSize.list = g_MapSizes.names;
    240         mapSize.list_data = g_MapSizes.tiles;
     217        mapSize.list = g_MapSizes.LongName;
     218        mapSize.list_data = g_MapSizes.Tiles;
    241219        mapSize.onSelectionChange = function() {
    242220            if (this.selected != -1)
    243                 g_GameAttributes.settings.Size = g_MapSizes.tiles[this.selected];
     221                g_GameAttributes.settings.Size = g_MapSizes.Tiles[this.selected];
    244222            updateGameAttributes();
    245223        };
    246224        mapSize.selected = 0;
    247225
    248226        Engine.GetGUIObjectByName("revealMap").onPress = function() {
     
    292270        Engine.GetGUIObjectByName("gameSpeedText").hidden = false;
    293271        Engine.GetGUIObjectByName("gameSpeed").hidden = true;
    294272
    295273        // Disable player and game options controls
    296274        // TODO: Shouldn't players be able to choose their own assignment?
    297         for (var i = 0; i < MAX_PLAYERS; ++i)
     275        for (let i = 0; i < g_Settings.MaxPlayers; ++i)
    298276        {
    299277            Engine.GetGUIObjectByName("playerAssignment["+i+"]").hidden = true;
    300278            Engine.GetGUIObjectByName("playerCiv["+i+"]").hidden = true;
    301279            Engine.GetGUIObjectByName("playerTeam["+i+"]").hidden = true;
    302280        }
     
    339317        }
    340318    }
    341319
    342320    // Settings for all possible player slots
    343321    var boxSpacing = 32;
    344     for (var i = 0; i < MAX_PLAYERS; ++i)
     322    for (let i = 0; i < g_Settings.MaxPlayers; ++i)
    345323    {
    346324        // Space player boxes
    347325        var box = Engine.GetGUIObjectByName("playerBox["+i+"]");
    348326        var boxSize = box.size;
    349327        var h = boxSize.bottom - boxSize.top;
    350328        boxSize.top = i * boxSpacing;
    351329        boxSize.bottom = i * boxSpacing + h;
    352330        box.size = boxSize;
    353331
    354332        // Populate team dropdowns
    355         var team = Engine.GetGUIObjectByName("playerTeam["+i+"]");
    356         team.list = [translateWithContext("team", "None"), "1", "2", "3", "4"];
    357         team.list_data = [-1, 0, 1, 2, 3];
     333        let team = Engine.GetGUIObjectByName("playerTeam["+i+"]");
     334        let teamsArray = Array(g_Settings.MaxTeams).fill(0).map((v, i) => i + 1); // 1, 2, ... MaxTeams
     335        team.list = [translateWithContext("team", "None")].concat(teamsArray); // "None", 1, 2, ..., maxTeams
     336        team.list_data = [-1].concat(teamsArray.map(player => player - 1)); // -1, 0, ..., (maxTeams-1)
    358337        team.selected = 0;
    359338
    360339        let playerSlot = i; // declare for inner function use
    361340        team.onSelectionChange = function() {
    362341            if (this.selected != -1)
     
    398377    }
    399378}
    400379
    401380function handleNetMessage(message)
    402381{
     382    if (!g_Settings)
     383        return;
     384
    403385    log("Net message: "+uneval(message));
    404386
    405387    switch (message.type)
    406388    {
    407389    case "netstatus":
     
    571553    //  Add random civ to beginning of list
    572554    civListNames.unshift('[color="orange"]' + translateWithContext("civilization", "Random") + '[/color]');
    573555    civListCodes.unshift("random");
    574556
    575557    // Update the dropdowns
    576     for (var i = 0; i < MAX_PLAYERS; ++i)
     558    for (let i = 0; i < g_Settings.MaxPlayers; ++i)
    577559    {
    578560        var civ = Engine.GetGUIObjectByName("playerCiv["+i+"]");
    579561        civ.list = civListNames;
    580562        civ.list_data = civListCodes;
    581563        civ.selected = 0;
     
    703685
    704686    // Ensure that cheats are enabled in singleplayer
    705687    if (!g_IsNetworked)
    706688        mapSettings.CheatsEnabled = true;
    707689
    708     var aiCodes = [ ai.id for each (ai in g_AIs) ];
    709690    var civListCodes = [ civ.Code for each (civ in g_CivData) if (civ.SelectableInGameSetup !== false) ];
    710691    civListCodes.push("random");
    711692
    712693    var playerData = mapSettings.PlayerData;
    713694
     
    762743    }
    763744
    764745    if (attrs.gameSpeed)
    765746    {
    766747        var gameSpeedBox = Engine.GetGUIObjectByName("gameSpeed");
    767         gameSpeedBox.selected = g_GameSpeeds.speeds.indexOf(attrs.gameSpeed);
     748        gameSpeedBox.selected = g_GameSpeeds.Speed.indexOf(attrs.gameSpeed);
    768749    }
    769750
    770751    if (!Engine.HasXmppClient())
    771752    {
    772753        g_GameAttributes.settings.RatingEnabled = false;
     
    787768    Engine.WriteJSONFile(g_IsNetworked ? FILEPATH_MATCHSETTINGS_MP : FILEPATH_MATCHSETTINGS_SP, attributes);
    788769}
    789770////////////////////////////////////////////////////////////////////////////////////////////////
    790771// GUI event handlers
    791772
     773function cancelAndReturn()
     774{
     775    cancelSetup();
     776    Engine.SwitchGuiPage(Engine.HasXmppClient() ? "page_lobby.xml" : "page_pregame.xml");
     777}
     778
    792779function cancelSetup()
    793780{
    794781    if (g_IsController)
    795782        saveGameAttributes();
    796783
     
    858845    }
    859846    else
    860847    {
    861848        // Add player data from defaults
    862849        for (var i = pData.length; i < num; ++i)
    863             g_GameAttributes.settings.PlayerData.push(g_DefaultPlayerData[i]);
     850            g_GameAttributes.settings.PlayerData.push(g_PlayerDefaults[i]);
    864851    }
    865852
    866853    // Some players may have lost their assigned slot
    867854    for (var guid in g_PlayerAssignments)
    868855    {
     
    908895        break;
    909896
    910897    case "skirmish":
    911898        g_GameAttributes.mapPath = "maps/skirmishes/";
    912899        g_GameAttributes.settings = {
    913             PlayerData: g_DefaultPlayerData.slice(0, 4),
     900            PlayerData: g_PlayerDefaults.slice(0, 4),
    914901            Seed: Math.floor(Math.random() * 65536),
    915902            AISeed: Math.floor(Math.random() * 65536),
    916903            CheatsEnabled: g_GameAttributes.settings.CheatsEnabled
    917904        };
    918905        break;
    919906
    920907    case "random":
    921908        g_GameAttributes.mapPath = "maps/random/";
    922909        g_GameAttributes.settings = {
    923             PlayerData: g_DefaultPlayerData.slice(0, 4),
     910            PlayerData: g_PlayerDefaults.slice(0, 4),
    924911            Seed: Math.floor(Math.random() * 65536),
    925912            AISeed: Math.floor(Math.random() * 65536),
    926913            CheatsEnabled: g_GameAttributes.settings.CheatsEnabled
    927914        };
    928915        break;
     
    975962            g_GameAttributes.settings[prop] = undefined;
    976963
    977964    var mapData = loadMapData(name);
    978965    var mapSettings = (mapData && mapData.settings ? deepcopy(mapData.settings) : {});
    979966
     967    // Reset victory conditions
     968    if (g_GameAttributes.mapType != "random")
     969    {
     970        let victoryIdx = mapSettings.GameType && g_GameTypes.Name.indexOf(mapSettings.GameType) != -1 ? g_GameTypes.Name.indexOf(mapSettings.GameType) : g_GameTypes.default;
     971        g_GameAttributes.settings.GameType = g_GameTypes.Name[victoryIdx];
     972        g_GameAttributes.settings.VictoryScripts = g_GameTypes.Scripts[victoryIdx];
     973    }
     974
    980975    // Copy any new settings
    981976    g_GameAttributes.map = name;
    982977    g_GameAttributes.script = mapSettings.Script;
    983978    if (g_GameAttributes.map !== "random")
    984979        for (var prop in mapSettings)
     
    990985
    991986    // Use default AI if the map doesn't specify any explicitly
    992987    for (var i = 0; i < g_GameAttributes.settings.PlayerData.length; ++i)
    993988    {
    994989        if (!('AI' in g_GameAttributes.settings.PlayerData[i]))
    995             g_GameAttributes.settings.PlayerData[i].AI = g_DefaultPlayerData[i].AI;
     990            g_GameAttributes.settings.PlayerData[i].AI = g_PlayerDefaults[i].AI;
    996991        if (!('AIDiff' in g_GameAttributes.settings.PlayerData[i]))
    997             g_GameAttributes.settings.PlayerData[i].AIDiff = g_DefaultPlayerData[i].AIDiff;
     992            g_GameAttributes.settings.PlayerData[i].AIDiff = g_PlayerDefaults[i].AIDiff;
    998993    }
    999994
    1000995    // Reset player assignments on map change
    1001996    if (!g_IsNetworked)
    1002997    {   // Slot 1
     
    10081003
    10091004        for (var guid in g_PlayerAssignments)
    10101005        {   // Unassign extra players
    10111006            var player = g_PlayerAssignments[guid].player;
    10121007
    1013             if (player <= MAX_PLAYERS && player > numPlayers)
     1008            if (player <= g_Settings.MaxPlayers && player > numPlayers)
    10141009                Engine.AssignNetworkPlayer(player, "");
    10151010        }
    10161011    }
    10171012
    10181013    updateGameAttributes();
     
    11331128
    11341129////////////////////////////////////////////////////////////////////////////////////////////////
    11351130
    11361131function onGameAttributesChange()
    11371132{
     1133    if (!g_Settings)
     1134        return;
     1135
    11381136    g_IsInGuiUpdate = true;
    11391137
    11401138    // Don't set any attributes here, just show the changes in GUI
    11411139
    11421140    var mapName = g_GameAttributes.map || "";
    11431141    var mapSettings = g_GameAttributes.settings;
    1144     var numPlayers = (mapSettings.PlayerData ? mapSettings.PlayerData.length : MAX_PLAYERS);
     1142    var numPlayers = mapSettings.PlayerData ? mapSettings.PlayerData.length : g_Settings.MaxPlayers;
    11451143
    11461144    // Update some controls for clients
    11471145    if (!g_IsController)
    11481146    {
    11491147        var mapFilterSelection = Engine.GetGUIObjectByName("mapFilterSelection");
     
    11571155        Engine.GetGUIObjectByName("mapSelectionText").caption = translate(getMapDisplayName(mapName));
    11581156        if (mapSettings.PopulationCap)
    11591157        {
    11601158            var populationCapBox = Engine.GetGUIObjectByName("populationCap");
    11611159            populationCapBox.selected = populationCapBox.list_data.indexOf(mapSettings.PopulationCap);
    1162         }       
     1160        }
    11631161        if (mapSettings.StartingResources)
    11641162        {
    11651163            var startingResourcesBox = Engine.GetGUIObjectByName("startingResources");
    11661164            startingResourcesBox.selected = startingResourcesBox.list_data.indexOf(mapSettings.StartingResources);
    11671165        }
     
    12041202    var ceasefireText = Engine.GetGUIObjectByName("ceasefireText");
    12051203    var gameSpeedText = Engine.GetGUIObjectByName("gameSpeedText");
    12061204    var gameSpeedBox = Engine.GetGUIObjectByName("gameSpeed");
    12071205
    12081206    // We have to check for undefined on these properties as not all maps define them.
    1209     var sizeIdx = (mapSettings.Size !== undefined && g_MapSizes.tiles.indexOf(mapSettings.Size) != -1 ? g_MapSizes.tiles.indexOf(mapSettings.Size) : g_MapSizes["default"]);
    1210     var speedIdx = (g_GameAttributes.gameSpeed !== undefined && g_GameSpeeds.speeds.indexOf(g_GameAttributes.gameSpeed) != -1) ? g_GameSpeeds.speeds.indexOf(g_GameAttributes.gameSpeed) : g_GameSpeeds["default"];
    1211     var victories = getVictoryConditions();
    1212     var victoryIdx = (mapSettings.GameType !== undefined && victories.data.indexOf(mapSettings.GameType) != -1 ? victories.data.indexOf(mapSettings.GameType) : VICTORY_DEFAULTIDX);
    1213     enableCheats.checked = (mapSettings.CheatsEnabled === undefined || !mapSettings.CheatsEnabled ? false : true)
     1207    var sizeIdx = mapSettings.Size && g_MapSizes.Tiles.indexOf(mapSettings.Size) != -1 ? g_MapSizes.Tiles.indexOf(mapSettings.Size) : g_MapSizes.default;
     1208    var speedIdx = g_GameAttributes.gameSpeed && g_GameSpeeds.Speed.indexOf(g_GameAttributes.gameSpeed) != -1 ? g_GameSpeeds.Speed.indexOf(g_GameAttributes.gameSpeed) : g_GameSpeeds.default;
     1209    var victoryIdx = mapSettings.GameType && g_GameTypes.Name.indexOf(mapSettings.GameType) != -1 ? g_GameTypes.Name.indexOf(mapSettings.GameType) : g_GameTypes.default;
     1210    enableCheats.checked = mapSettings.CheatsEnabled ? true : false;
    12141211    enableCheatsText.caption = (enableCheats.checked ? translate("Yes") : translate("No"));
    12151212    if (mapSettings.RatingEnabled !== undefined)
    12161213    {
    12171214        enableRating.checked = mapSettings.RatingEnabled;
    12181215        Engine.SetRankedGame(enableRating.checked);
     
    12201217        enableCheats.enabled = !enableRating.checked;
    12211218        lockTeams.enabled = !enableRating.checked;
    12221219    }
    12231220    else
    12241221        enableRatingText.caption = "Unknown";
    1225     gameSpeedText.caption = g_GameSpeeds.names[speedIdx];
     1222    gameSpeedText.caption = g_GameSpeeds.Title[speedIdx];
    12261223    gameSpeedBox.selected = speedIdx;
    1227     populationCap.selected = (mapSettings.PopulationCap !== undefined && POPULATION_CAP_DATA.indexOf(mapSettings.PopulationCap) != -1 ? POPULATION_CAP_DATA.indexOf(mapSettings.PopulationCap) : POPULATION_CAP_DEFAULTIDX);
    1228     populationCapText.caption = POPULATION_CAP[populationCap.selected];
    1229     startingResources.selected = (mapSettings.StartingResources !== undefined && STARTING_RESOURCES_DATA.indexOf(mapSettings.StartingResources) != -1 ? STARTING_RESOURCES_DATA.indexOf(mapSettings.StartingResources) : STARTING_RESOURCES_DEFAULTIDX);
    1230     startingResourcesText.caption = STARTING_RESOURCES[startingResources.selected];
    1231     ceasefire.selected = (mapSettings.Ceasefire !== undefined && CEASEFIRE_DATA.indexOf(mapSettings.Ceasefire) != -1 ? CEASEFIRE_DATA.indexOf(mapSettings.Ceasefire) : CEASEFIRE_DEFAULTIDX);
    1232     ceasefireText.caption = CEASEFIRE[ceasefire.selected];
     1224    populationCap.selected = mapSettings.PopulationCap && g_PopulationCapacity.Population.indexOf(mapSettings.PopulationCap) != -1 ? g_PopulationCapacity.Population.indexOf(mapSettings.PopulationCap) : g_PopulationCapacity.default;
     1225    populationCapText.caption = g_PopulationCapacity.Title[populationCap.selected];
     1226    startingResources.selected = mapSettings.StartingResources && g_StartingResources.Resources.indexOf(mapSettings.StartingResources) != -1 ? g_StartingResources.Resources.indexOf(mapSettings.StartingResources) : g_StartingResources.default;
     1227    startingResourcesText.caption = g_StartingResources.Title[startingResources.selected];
     1228    ceasefire.selected = mapSettings.Ceasefire !== undefined && g_Ceasefire.Duration.indexOf(mapSettings.Ceasefire) != -1 ? g_Ceasefire.Duration.indexOf(mapSettings.Ceasefire) : g_Ceasefire.default;
     1229    ceasefireText.caption = g_Ceasefire.Title[ceasefire.selected];
    12331230
    12341231    // Update map preview
    12351232    Engine.GetGUIObjectByName("mapPreview").sprite = "cropped:(0.78125,0.5859375)session/icons/mappreview/" + getMapPreview(mapName);
    12361233
    12371234    // Hide/show settings depending on whether we can change them or not
     
    12701267        }
    12711268        else
    12721269        {
    12731270            // Client
    12741271            numPlayersText.caption = numPlayers;
    1275             mapSizeText.caption = g_MapSizes.names[sizeIdx];
     1272            mapSizeText.caption = g_MapSizes.LongName[sizeIdx];
    12761273            revealMapText.caption = (mapSettings.RevealMap ? translate("Yes") : translate("No"));
    12771274            exploreMapText.caption = (mapSettings.ExporeMap ? translate("Yes") : translate("No"));
    12781275            disableTreasuresText.caption = (mapSettings.DisableTreasures ? translate("Yes") : translate("No"));
    1279             victoryConditionText.caption = victories.text[victoryIdx];
     1276            victoryConditionText.caption = g_GameTypes.Title[victoryIdx];
    12801277            lockTeamsText.caption = (mapSettings.LockTeams ? translate("Yes") : translate("No"));
    12811278        }
    12821279
    12831280        break;
    12841281
     
    13131310        {
    13141311            // Client
    13151312            revealMapText.caption = (mapSettings.RevealMap ? translate("Yes") : translate("No"));
    13161313            exploreMapText.caption = (mapSettings.ExploreMap ? translate("Yes") : translate("No"));
    13171314            disableTreasuresText.caption = (mapSettings.DisableTreasures ? translate("Yes") : translate("No"));
    1318             victoryConditionText.caption = victories.text[victoryIdx];
     1315            victoryConditionText.caption = g_GameTypes.Title[victoryIdx];
    13191316            lockTeamsText.caption = (mapSettings.LockTeams ? translate("Yes") : translate("No"));
    13201317        }
    13211318
    13221319        break;
    13231320
     
    13431340        startingResourcesText.hidden = false;
    13441341        populationCap.hidden = true;
    13451342        populationCapText.hidden = false;
    13461343        ceasefire.hidden = true;
    13471344        ceasefireText.hidden = false;
    1348        
     1345
    13491346        numPlayersText.caption = numPlayers;
    13501347        mapSizeText.caption = translate("Default");
    13511348        revealMapText.caption = (mapSettings.RevealMap ? translate("Yes") : translate("No"));
    13521349        exploreMapText.caption = (mapSettings.ExploreMap ? translate("Yes") : translate("No"));
    13531350        disableTreasuresText.caption = translate("No");
    1354         victoryConditionText.caption = victories.text[victoryIdx];
     1351        victoryConditionText.caption = g_GameTypes.Title[victoryIdx];
    13551352        lockTeamsText.caption = (mapSettings.LockTeams ? translate("Yes") : translate("No"));
    13561353
    13571354        startingResourcesText.caption = translate("Determined by scenario");
    13581355        populationCapText.caption = translate("Determined by scenario");
    13591356        ceasefireText.caption = translate("Determined by scenario");
     
    13771374    // Load the description from the map file, if there is one
    13781375    var description = mapSettings.Description ? translate(mapSettings.Description) : translate("Sorry, no description available.");
    13791376
    13801377    // Describe the number of players and the victory conditions
    13811378    var playerString = sprintf(translatePlural("%(number)s player. ", "%(number)s players. ", numPlayers), { number: numPlayers });
    1382     let victory = translate(victories.text[victoryIdx]);
    1383     if (victoryIdx != VICTORY_DEFAULTIDX)
     1379    let victory = translate(g_GameTypes.Title[victoryIdx]);
     1380    if (victoryIdx != g_GameTypes.default)
    13841381        victory = "[color=\"orange\"]" + victory + "[/color]";
    13851382    playerString += translate("Victory Condition:") + " " + victory + ".\n\n" + description;
    13861383
    1387     for (var i = 0; i < MAX_PLAYERS; ++i)
     1384    for (let i = 0; i < g_Settings.MaxPlayers; ++i)
    13881385    {
    13891386        // Show only needed player slots
    13901387        Engine.GetGUIObjectByName("playerBox["+i+"]").hidden = (i >= numPlayers);
    13911388
    13921389        // Show player data or defaults as necessary
     
    14021399        var pTeamText = Engine.GetGUIObjectByName("playerTeamText["+i+"]");
    14031400        var pColor = Engine.GetGUIObjectByName("playerColor["+i+"]");
    14041401
    14051402        // Player data / defaults
    14061403        var pData = mapSettings.PlayerData ? mapSettings.PlayerData[i] : {};
    1407         var pDefs = g_DefaultPlayerData ? g_DefaultPlayerData[i] : {};
     1404        var pDefs = g_PlayerDefaults[i];;
    14081405
    14091406        // Common to all game types
    14101407        var color = rgbToGuiColor(getSetting(pData, pDefs, "Color"));
    14111408        pColor.sprite = "color:" + color + " 100";
    14121409        pName.caption = translate(getSetting(pData, pDefs, "Name"));
     
    15131510
    15141511    // Only enable start button if we have enough assigned players
    15151512    if (g_IsController)
    15161513        Engine.GetGUIObjectByName("startGame").enabled = (g_AssignedCount > 0);
    15171514
    1518     for each (var ai in g_AIs)
     1515    var ais = initAIDescription();
     1516    for (let ai of ais)
    15191517    {
    15201518        if (ai.data.hidden)
    15211519        {
    15221520            // If the map uses a hidden AI then don't hide it
    15231521            var usedByMap = false;
    1524             for (var i = 0; i < MAX_PLAYERS; ++i)
     1522            for (let i = 0; i < g_Settings.MaxPlayers; ++i)
    15251523                if (i < g_GameAttributes.settings.PlayerData.length &&
    15261524                    g_GameAttributes.settings.PlayerData[i].AI == ai.id)
    15271525                {
    15281526                    usedByMap = true;
    15291527                    break;
     
    15401538
    15411539    noAssignment = hostNameList.length;
    15421540    hostNameList.push("[color=\"140 140 140 255\"]" + translate("Unassigned"));
    15431541    hostGuidList.push("");
    15441542
    1545     for (var i = 0; i < MAX_PLAYERS; ++i)
     1543    for (let i = 0; i < g_Settings.MaxPlayers; ++i)
    15461544    {
    15471545        let playerSlot = i;
    15481546        let playerID = i+1; // we don't show Gaia, so first slot is ID 1
    15491547
    15501548        var selection = assignments[playerID];
     
    15791577            if (g_IsController)
    15801578            {
    15811579                configButton.hidden = false;
    15821580                configButton.onpress = function() {
    15831581                    Engine.PushGuiPage("page_aiconfig.xml", {
    1584                         ais: g_AIs,
    1585                         id: g_GameAttributes.settings.PlayerData[playerSlot].AI,
    1586                         difficulty: g_GameAttributes.settings.PlayerData[playerSlot].AIDiff,
    1587                         callback: "AIConfigCallback",
    1588                         playerSlot: playerSlot // required by the callback function
     1582                        "ais": ais,
     1583                        "id": g_GameAttributes.settings.PlayerData[playerSlot].AI,
     1584                        "difficulty": g_GameAttributes.settings.PlayerData[playerSlot].AIDiff,
     1585                        "difficulties" : g_AIDiffs,
     1586                        "callback": "AIConfigCallback",
     1587                        "playerSlot": playerSlot // required by the callback function
    15891588                    });
    15901589                };
    15911590            }
    15921591        }
    15931592        // There was a human, so make sure we don't have any AI left
     
    17111710        var player = g_PlayerAssignments[msg.guid].player - 1;
    17121711        var mapName = g_GameAttributes.map;
    17131712        var mapData = loadMapData(mapName);
    17141713        var mapSettings = (mapData && mapData.settings ? mapData.settings : {});
    17151714        var pData = mapSettings.PlayerData ? mapSettings.PlayerData[player] : {};
    1716         var pDefs = g_DefaultPlayerData ? g_DefaultPlayerData[player] : {};
     1715        var pDefs = g_PlayerDefaults[player];
    17171716
    17181717        color = rgbToGuiColor(getSetting(pData, pDefs, "Color"));
    17191718    }
    17201719
    17211720    var formatted;
     
    17841783
    17851784function updateReadyUI()
    17861785{
    17871786    if (!g_IsNetworked)
    17881787        return; // Disabled for single-player games.
    1789     var isAI = new Array(MAX_PLAYERS + 1);
     1788    var isAI = new Array(g_Settings.MaxPlayers + 1);
    17901789    for (var i = 0; i < isAI.length; ++i)
    17911790        isAI[i] = true;
    17921791    var allReady = true;
    17931792    for (var guid in g_PlayerAssignments)
    17941793    {
    17951794        // We don't really care whether observers are ready.
    17961795        if (g_PlayerAssignments[guid].player == -1 || !g_GameAttributes.settings.PlayerData[g_PlayerAssignments[guid].player - 1])
    17971796            continue;
    17981797        var pData = g_GameAttributes.settings.PlayerData ? g_GameAttributes.settings.PlayerData[g_PlayerAssignments[guid].player - 1] : {};
    1799         var pDefs = g_DefaultPlayerData ? g_DefaultPlayerData[g_PlayerAssignments[guid].player - 1] : {};
     1798        var pDefs = g_PlayerDefaults[g_PlayerAssignments[guid].player - 1];
    18001799        isAI[g_PlayerAssignments[guid].player] = false;
    18011800        if (g_PlayerAssignments[guid].status || !g_IsNetworked)
    18021801            Engine.GetGUIObjectByName("playerName[" + (g_PlayerAssignments[guid].player - 1) + "]").caption = '[color="0 255 0"]' + translate(getSetting(pData, pDefs, "Name")) + '[/color]';
    18031802        else
    18041803        {
    18051804            Engine.GetGUIObjectByName("playerName[" + (g_PlayerAssignments[guid].player - 1) + "]").caption = translate(getSetting(pData, pDefs, "Name"));
    18061805            allReady = false;
    18071806        }
    18081807    }
    18091808    // AIs are always ready.
    1810     for (var playerid = 0; playerid < MAX_PLAYERS; ++playerid)
    1811     {       
     1809    for (let playerid = 0; playerid < g_Settings.MaxPlayers; ++playerid)
     1810    {
    18121811        if (!g_GameAttributes.settings.PlayerData[playerid])
    18131812            continue;
    18141813        var pData = g_GameAttributes.settings.PlayerData ? g_GameAttributes.settings.PlayerData[playerid] : {};
    1815         var pDefs = g_DefaultPlayerData ? g_DefaultPlayerData[playerid] : {};
     1814        var pDefs = g_PlayerDefaults[playerid];
    18161815        if (isAI[playerid + 1])
    18171816            Engine.GetGUIObjectByName("playerName[" + playerid + "]").caption = '[color="0 255 0"]' + translate(getSetting(pData, pDefs, "Name")) + '[/color]';
    18181817    }
    18191818
    18201819    // The host is not allowed to start until everyone is ready.
     
    19681967        "tnbp":tnbp,
    19691968        "players":players
    19701969    };
    19711970    Engine.SendRegisterGame(gameData);
    19721971}
    1973 
    1974 function getVictoryConditions()
    1975 {
    1976     var r = {};
    1977     r.text = [translate("None")];
    1978     r.data = ["endless"];
    1979     r.scripts = [[]];
    1980     for (var vc in g_VictoryConditions)
    1981     {
    1982         r.data.push(vc);
    1983         r.text.push(g_VictoryConditions[vc].name);
    1984         r.scripts.push(g_VictoryConditions[vc].scripts);
    1985     }
    1986     return r;
    1987 }
  • binaries/data/mods/public/gui/gamesetup/gamesetup.xml

     
    11<?xml version="1.0" encoding="utf-8"?>
    22
    33<objects>
    44
    5     <script file="gui/common/network.js"/>
    65    <script file="gui/common/functions_civinfo.js"/>
    76    <script file="gui/common/functions_global_object.js"/>
    87    <script file="gui/common/functions_utility.js"/>
     8    <script file="gui/common/network.js"/>
     9    <script file="gui/common/settings.js"/>
    910    <script file="gui/gamesetup/gamesetup.js"/>
    10     <!-- After gamesetup.js which defines g_VictoryConditions -->
    11     <script directory="gui/gamesetup/victory_conditions/"/>
    1211
    1312    <!-- Add a translucent black background to fade out the menu page -->
    1413    <object type="image" style="ModernWindow" size="0 0 100% 100%">
    1514
    1615        <object style="TitleText" type="text" size="50%-128 4 50%+128 36">
     
    237236                style="StoneButton"
    238237                size="100%-308 100%-52 100%-168 100%-24"
    239238                tooltip_style="onscreenToolTip"
    240239            >
    241240                <translatableAttribute id="caption">Back</translatableAttribute>
    242                 <action on="Press">
    243                     <![CDATA[
    244                         cancelSetup();
    245                         if(!Engine.HasXmppClient())
    246                             Engine.SwitchGuiPage("page_pregame.xml");
    247                         else
    248                             Engine.SwitchGuiPage("page_lobby.xml");
    249                     ]]>
    250                 </action>
     241                <action on="Press">cancelAndReturn();</action>
    251242            </object>
    252243
    253244            <!-- Options -->
    254245            <object name="gameOptionsBox" size="100%-425 529 100%-25 525">
    255246                <!-- More Options Button -->
  • binaries/data/mods/public/gui/gamesetup/victory_conditions/conquest.js

     
    1 g_VictoryConditions.conquest = {
    2     "name" : translate("Conquest"),
    3     "description" : translate("Defeat all opponents"),
    4     "scripts" : ["scripts/ConquestCommon.js", "scripts/TriggerHelper.js", "scripts/Conquest.js"]
    5 };
  • binaries/data/mods/public/gui/gamesetup/victory_conditions/conquestStructures.js

     
    1 g_VictoryConditions.conquestStructure = {
    2     "name" : translate("Conquest Structures"),
    3     "description" : translate("Destroy all structures of enemies"),
    4     "scripts" : ["scripts/ConquestCommon.js", "scripts/TriggerHelper.js", "scripts/ConquestStructures.js"]
    5 };
  • binaries/data/mods/public/gui/gamesetup/victory_conditions/conquestUnits.js

     
    1 g_VictoryConditions.conquestUnits = {
    2     "name" : translate("Conquest Units"),
    3     "description" : translate("Destroy all units of enemies"),
    4     "scripts" : ["scripts/ConquestCommon.js", "scripts/TriggerHelper.js", "scripts/ConquestUnits.js"]
    5 };
  • binaries/data/mods/public/gui/gamesetup/victory_conditions/wonder.js

     
    1 g_VictoryConditions.wonder = {
    2     "name" : translate("Wonder"),
    3     "description" : translate("Build a wonder to win"),
    4     "scripts" : ["scripts/ConquestCommon.js", "scripts/TriggerHelper.js", "scripts/Conquest.js", "scripts/WonderVictory.js"]
    5 };
  • binaries/data/mods/public/gui/lobby/lobby.js

     
     1const g_specialKey = Math.random();
     2const g_timestamp = Engine.ConfigDB_GetValue("user", "lobby.chattimestamp") == "true";
     3const g_modPrefix = "@";
     4const SPAM_BLOCK_LENGTH = 30;
     5
    16var g_ChatMessages = [];
    27var g_Name = "unknown";
    38var g_GameList = {}
    49var g_GameListSortBy = "name";
    510var g_PlayerListSortBy = "name";
    611var g_GameListOrder = 1; // 1 for ascending sort, and -1 for descending
    712var g_PlayerListOrder = 1;
    8 var g_specialKey = Math.random();
    913// This object looks like {"name":[numMessagesSinceReset, lastReset, timeBlocked]} when in use.
    1014var g_spamMonitor = {};
    11 var g_timestamp = Engine.ConfigDB_GetValue("user", "lobby.chattimestamp") == "true";
    12 var g_mapSizes = {};
    13 const g_mapTypesText = [translateWithContext("map", "Skirmish"), translateWithContext("map", "Random"), translate("Scenario")];
    14 const g_mapTypes = ["skirmish", "random", "scenario"];
    1515var g_userRating = ""; // Rating of user, defaults to Unrated
    16 var g_modPrefix = "@";
    1716var g_joined = false;
    18 // Block spammers for 30 seconds.
    19 var SPAM_BLOCK_LENGTH = 30;
    2017
    2118////////////////////////////////////////////////////////////////////////////////////////////////
    2219
    2320function init(attribs)
    2421{
     22    if (!validSettings(returnToMainMenu))
     23        return;
     24
    2525    // Play menu music
    2626    initMusic();
    2727    global.music.setState(global.music.states.MENU);
    2828
    29     g_Name = Engine.LobbyGetNick();
    30 
    31     g_mapSizes = initMapSizes();
    32     g_mapSizes.shortNames.splice(0, 0, translateWithContext("map size", "Any"));
    33     g_mapSizes.tiles.splice(0, 0, "");
    34 
     29    // Setup mapsize filter
    3530    var mapSizeFilter = Engine.GetGUIObjectByName("mapSizeFilter");
    36     mapSizeFilter.list = g_mapSizes.shortNames;
    37     mapSizeFilter.list_data = g_mapSizes.tiles;
     31    var mapSizes = prepareForDropdown("MapSizes");
     32    mapSizeFilter.list = [translateWithContext("map size", "Any")].concat(mapSizes.Name);
     33    mapSizeFilter.list_data = [""].concat(mapSizes.Tiles);
    3834
     35    // Setup playercount filter
     36    var playersArray = Array(g_Settings.MaxPlayers - 1).fill(0).map((value, index) => index + 2); // 2, 3, ... MaxPlayers
    3937    var playersNumberFilter = Engine.GetGUIObjectByName("playersNumberFilter");
    40     playersNumberFilter.list = [translateWithContext("player number", "Any"),2,3,4,5,6,7,8];
    41     playersNumberFilter.list_data = ["",2,3,4,5,6,7,8];
     38    playersNumberFilter.list = [translateWithContext("player number", "Any")].concat(playersArray);
     39    playersNumberFilter.list_data = [""].concat(playersArray);
    4240
     41    // Setup maptype filter
    4342    var mapTypeFilter = Engine.GetGUIObjectByName("mapTypeFilter");
    44     mapTypeFilter.list = [translateWithContext("map", "Any")].concat(g_mapTypesText);
    45     mapTypeFilter.list_data = [""].concat(g_mapTypes);
     43    var mapTypes = prepareForDropdown("MapTypes");
     44    mapTypeFilter.list = [translateWithContext("map type", "Any")].concat(mapTypes.Title);
     45    mapTypeFilter.list_data = [""].concat(mapTypes.Name);
    4646
     47    // Init GUI elements
     48    g_Name = Engine.LobbyGetNick();
    4749    Engine.LobbySetPlayerPresence("available");
    4850    Engine.SendGetGameList();
    4951    Engine.SendGetBoardList();
    5052    Engine.SendGetRatingList();
    5153    updatePlayerList();
     
    468470            else
    469471                name = '[color="255 0 0"]' + name + '[/color]';
    470472            list_name.push(name);
    471473            list_ip.push(g.ip);
    472474            list_mapName.push(translate(g.niceMapName));
    473             list_mapSize.push(translatedMapSize(g.mapSize));
    474             let idx = g_mapTypes.indexOf(g.mapType);
    475             list_mapType.push(idx != -1 ? g_mapTypesText[idx] : "");
     475            list_mapSize.push(translateMapSize(g.mapSize));
     476            list_mapType.push(translateMapType(g.mapType));
    476477            list_nPlayers.push(g.nbp + "/" +g.tnbp);
    477478            list.push(name);
    478479            list_data.push(c);
    479480        }
    480481        c++;
     
    546547    // Push this player's name and status onto the list
    547548    return [formattedName, formattedStatus, formattedRating];
    548549}
    549550
    550551/**
    551  * Given a map size, returns that map size translated into the current
    552  * language.
    553  */
    554 function translatedMapSize(mapSize)
    555 {
    556     if (+mapSize !== +mapSize) // NaN
    557         return translate(mapSize);
    558     else
    559         return g_mapSizes.shortNames[g_mapSizes.tiles.indexOf(+mapSize)];
    560 }
    561 
    562 /**
    563552 * Populate the game info area with information on the current game selection.
    564553 */
    565554function updateGameSelection()
    566555{
    567556    var selected = Engine.GetGUIObjectByName("gamesBox").selected;
     
    572561        Engine.GetGUIObjectByName("joinGameButton").hidden = true;
    573562        Engine.GetGUIObjectByName("gameInfoEmpty").hidden = false;
    574563        return;
    575564    }
    576565
    577     var mapData;
    578566    var g = Engine.GetGUIObjectByName("gamesBox").list_data[selected];
    579567
    580     // Load map data
    581     if (g_GameList[g].mapType == "random" && g_GameList[g].mapName == "random")
    582         mapData = {"settings": {"Description": translate("A randomly selected map.")}};
    583     else if (g_GameList[g].mapType == "random" && Engine.FileExists(g_GameList[g].mapName + ".json"))
    584         mapData = Engine.ReadJSONFile(g_GameList[g].mapName + ".json");
    585     else if (Engine.FileExists(g_GameList[g].mapName + ".xml"))
    586         mapData = Engine.LoadMapSettings(g_GameList[g].mapName + ".xml");
    587     else
    588         // Warn the player if we can't find the map.
    589         warn(sprintf("Map '%(mapName)s' not found locally.", { mapName: g_GameList[g].mapName }));
    590 
    591568    // Show the game info panel and join button.
    592569    Engine.GetGUIObjectByName("gameInfo").hidden = false;
    593570    Engine.GetGUIObjectByName("joinGameButton").hidden = false;
    594571    Engine.GetGUIObjectByName("gameInfoEmpty").hidden = true;
    595572
    596573    // Display the map name, number of players, the names of the players, the map size and the map type.
    597574    Engine.GetGUIObjectByName("sgMapName").caption = translate(g_GameList[g].niceMapName);
    598575    Engine.GetGUIObjectByName("sgNbPlayers").caption = g_GameList[g].nbp + "/" + g_GameList[g].tnbp;
    599576    Engine.GetGUIObjectByName("sgPlayersNames").caption = g_GameList[g].players;
    600     Engine.GetGUIObjectByName("sgMapSize").caption = translatedMapSize(g_GameList[g].mapSize);
    601     let idx = g_mapTypes.indexOf(g_GameList[g].mapType);
    602     Engine.GetGUIObjectByName("sgMapType").caption = idx != -1 ? g_mapTypesText[idx] : "";
    603 
    604     // Display map description if it exists, otherwise display a placeholder.
    605     if (mapData && mapData.settings.Description)
    606         var mapDescription = translate(mapData.settings.Description);
    607     else
    608         var mapDescription = translate("Sorry, no description available.");
     577    Engine.GetGUIObjectByName("sgMapSize").caption = translateMapSize(g_GameList[g].mapSize);
     578    Engine.GetGUIObjectByName("sgMapType").caption = translateMapType(g_GameList[g].mapType);
    609579
    610     // Display map preview if it exists, otherwise display a placeholder.
    611     if (mapData && mapData.settings.Preview)
    612         var mapPreview = mapData.settings.Preview;
    613     else
    614         var mapPreview = "nopreview.png";
    615 
    616     Engine.GetGUIObjectByName("sgMapDescription").caption = mapDescription;
    617     Engine.GetGUIObjectByName("sgMapPreview").sprite = "cropped:(0.7812,0.5859)session/icons/mappreview/" + mapPreview;
     580    // Display map description and preview (or placeholder)
     581    let mapData = getMapDescriptionAndPreview(g_GameList[g].mapType, g_GameList[g].mapName);
     582    Engine.GetGUIObjectByName("sgMapDescription").caption = mapData.description;
     583    Engine.GetGUIObjectByName("sgMapPreview").sprite = "cropped:(0.7812,0.5859)session/icons/mappreview/" + mapData.preview;
    618584}
    619585
    620586/**
    621587 * Start the joining process on the currectly selected game.
    622588 */
     
    859825        break;
    860826    case "ban": // TODO: Split reason from nick and pass it too, for now just support "/ban nick"
    861827        Engine.LobbyBan(nick, "");
    862828        break;
    863829    case "quit":
    864         lobbyStop();
    865         Engine.SwitchGuiPage("page_pregame.xml");
     830        returnToMainMenu();
    866831        break;
    867832    case "say":
    868833    case "me":
    869834        return false;
    870835    default:
     
    10881053        }
    10891054    }
    10901055
    10911056}
    10921057
     1058function returnToMainMenu()
     1059{
     1060    lobbyStop();
     1061    Engine.SwitchGuiPage("page_pregame.xml");
     1062}
     1063
    10931064/* Utilities */
    10941065// Generate a (mostly) unique color for this player based on their name.
    10951066// See http://stackoverflow.com/questions/3426404/create-a-hexadecimal-colour-based-on-a-string-with-jquery-javascript
    10961067function getPlayerColor(playername)
    10971068{
  • binaries/data/mods/public/gui/lobby/lobby.xml

     
    33<objects>
    44    <script file="gui/common/functions_global_object.js"/>
    55    <script file="gui/common/functions_utility.js"/>
    66    <script file="gui/common/timer.js"/>
    77    <script file="gui/common/music.js"/>
     8    <script file="gui/common/settings.js"/>
    89
    910    <script file="gui/lobby/lobby.js"/>
    1011
    1112    <object type="image" style="ModernWindow" size="0 0 100% 100%" name="lobbyWindow">
    1213
     
    161162                </action>
    162163            </object>
    163164
    164165            <object type="button" style="ModernButtonRed" size="0 100%-25 100% 100%">
    165166                <translatableAttribute id="caption">Main Menu</translatableAttribute>
    166                 <action on="Press">
    167                     lobbyStop();
    168                     Engine.SwitchGuiPage("page_pregame.xml");
    169                 </action>
     167                <action on="Press">returnToMainMenu();</action>
    170168            </object>
    171169        </object>
    172170
    173171        <!-- Middle panel: Filters, game list, chat box. -->
    174172        <object name="middlePanel" size="20%+5 5% 100%-255 97.2%">
  • binaries/data/mods/public/gui/session/session.js

     
    1111// Cache the basic player data (name, civ, color)
    1212var g_Players = [];
    1313// Cache the useful civ data
    1414var g_CivData = {};
    1515
    16 var g_GameSpeeds = {};
    17 var g_CurrentSpeed;
    18 
    1916var g_PlayerAssignments = { "local": { "name": translate("You"), "player": 1 } };
    2017
    2118// Cache dev-mode settings that are frequently or widely used
    2219var g_DevSettings = {
    2320    controlAll: false
     
    142139    }
    143140
    144141    return g_TechnologyData[technologyName];
    145142}
    146143
    147 // Init
    148144function init(initData, hotloadData)
    149145{
     146    initMusic();
     147
     148    if (!validSettings(() => { leaveGame(true); }))
     149        return;
     150
    150151    if (initData)
    151152    {
    152153        g_IsNetworked = initData.isNetworked; // Set network mode
    153154        g_IsController = initData.isController; // Set controller mode
    154155        g_PlayerAssignments = initData.playerAssignments;
     
    175176    if (Engine.GetPlayerID() <= 0)
    176177        g_IsObserver = true;
    177178
    178179    updateTopPanel();
    179180
    180     g_GameSpeeds = initGameSpeeds();
    181     g_CurrentSpeed = Engine.GetSimRate();
    182181    var gameSpeed = Engine.GetGUIObjectByName("gameSpeed");
    183     gameSpeed.list = g_GameSpeeds.names;
    184     gameSpeed.list_data = g_GameSpeeds.speeds;
    185     var idx = g_GameSpeeds.speeds.indexOf(g_CurrentSpeed);
    186     gameSpeed.selected = idx != -1 ? idx : g_GameSpeeds["default"];
     182    var gameSpeeds = prepareForDropdown("GameSpeeds");
     183    gameSpeed.list = gameSpeeds.Title;
     184    gameSpeed.list_data = gameSpeeds.Speed;
     185    var idx = gameSpeed.list_data.indexOf(Engine.GetSimRate());
     186    gameSpeed.selected = idx != -1 ? idx : gameSpeeds.default;
    187187    gameSpeed.onSelectionChange = function() { changeGameSpeed(+this.list_data[this.selected]); }
    188188    initMenuPosition(); // set initial position
    189189
    190190    // Populate player selection dropdown
    191191    var playerNames = [];
     
    207207
    208208    if (hotloadData)
    209209        g_Selection.selected = hotloadData.selection;
    210210
    211211    // Starting for the first time:
    212     initMusic();
    213212    if (!g_IsObserver)
    214213    {
    215214        var civMusic = g_CivData[g_Players[Engine.GetPlayerID()].civ].Music;
    216215        global.music.storeTracks(civMusic);
    217216    }
     
    398397/**
    399398 * Called every frame.
    400399 */
    401400function onTick()
    402401{
     402    if (!g_Settings)
     403        return;
     404
    403405    var now = new Date;
    404406    var tickLength = new Date - lastTickTime;
    405407    lastTickTime = now;
    406408
    407409    checkPlayerState();
     
    507509
    508510function changeGameSpeed(speed)
    509511{
    510512    // For non-networked games only
    511513    if (!g_IsNetworked)
    512     {
    513514        Engine.SetSimRate(speed);
    514         g_CurrentSpeed = speed;
    515     }
    516515}
    517516
    518517/**
    519518 * Recomputes GUI state that depends on simulation state or selection state. Called directly every simulation
    520519 * update (see session.xml), or from onTick when the selection has changed.
  • binaries/data/mods/public/gui/session/session.xml

     
    66<script file="gui/common/functions_civinfo.js"/>
    77<script file="gui/common/functions_global_object.js"/>
    88<script file="gui/common/functions_utility.js"/>
    99<script file="gui/common/l10n.js"/>
    1010<script file="gui/common/music.js"/>
     11<script file="gui/common/settings.js"/>
    1112<script file="gui/common/timer.js"/>
    1213<script file="gui/common/tooltips.js"/>
    1314<!-- load all scripts in this directory -->
    1415<script directory="gui/session/"/>
    1516
  • binaries/data/mods/public/gui/summary/layout.js

     
    141141{
    142142    for (var h = 0; h < MAX_HEADINGTITLE; ++h)
    143143    {
    144144        Engine.GetGUIObjectByName("titleHeading["+ h +"]").hidden = true;
    145145        Engine.GetGUIObjectByName("Heading[" + h + "]").hidden = true;
    146         for (var p = 0; p < MAX_SLOTS; ++p)
     146        for (let p = 0; p < g_Settings.MaxPlayers; ++p)
    147147        {
    148148            Engine.GetGUIObjectByName("valueData[" + p + "][" + h + "]").hidden = true;
    149             for (var t = 0; t < MAX_TEAMS; ++t)
     149            for (let t = 0; t < g_Settings.MaxTeams; ++t)
    150150            {
    151151                Engine.GetGUIObjectByName("valueDataTeam[" + t + "][" + p + "][" + h + "]").hidden = true;
    152152                Engine.GetGUIObjectByName("valueDataTeam[" + t + "][" + h + "]").hidden = true;
    153153            }
    154154        }
     
    191191
    192192function updateGeneralPanelCounter(counters)
    193193{
    194194    var rowPlayerObjectWidth = 0;
    195195    var left = 0;
    196     for (var p = 0; p < MAX_SLOTS; ++p)
     196    for (let p = 0; p < g_Settings.MaxPlayers; ++p)
    197197    {
    198198        left = 240;
    199199        var counterObject;
    200200        for (var w in counters)
    201201        {
     
    206206        }
    207207        if (rowPlayerObjectWidth == 0)
    208208            rowPlayerObjectWidth = left;
    209209
    210210        var counterTotalObject;
    211         for (var t = 0; t < MAX_TEAMS; ++t)
     211        for (let t = 0; t < g_Settings.MaxTeams; ++t)
    212212        {
    213213            left = 240;
    214214            for (var w in counters)
    215215            {
    216216                counterObject = Engine.GetGUIObjectByName("valueDataTeam[" + t + "][" + p + "][" + w + "]");
     
    266266        Engine.GetGUIObjectByName("playerNameHeading").caption = "";
    267267}
    268268
    269269function updateObjectPlayerPosition()
    270270{
    271     for (var h = 0; h < MAX_SLOTS; ++h)
     271    for (let h = 0; h < g_Settings.MaxPlayers; ++h)
    272272    {
    273273        var playerBox = Engine.GetGUIObjectByName("playerBox[" + h + "]");
    274274        var boxSize = playerBox.size;
    275275        boxSize.top += h * (PLAYER_BOX_Y_SIZE + PLAYER_BOX_GAP);
    276276        boxSize.bottom = boxSize.top + PLAYER_BOX_Y_SIZE;
    277277        playerBox.size = boxSize;
    278278
    279         for (var i = 0; i < MAX_TEAMS; ++i)
     279        for (let i = 0; i < g_Settings.MaxTeams; ++i)
    280280        {
    281281            var playerBoxt = Engine.GetGUIObjectByName("playerBoxt[" + i + "][" + h + "]");
    282282            boxSize = playerBoxt.size;
    283283            boxSize.top += h * (PLAYER_BOX_Y_SIZE + PLAYER_BOX_GAP);
    284284            boxSize.bottom = boxSize.top + PLAYER_BOX_Y_SIZE;
  • binaries/data/mods/public/gui/summary/summary.js

     
    1 // Max player slots for any map (TODO: should read from config)
    2 const MAX_SLOTS = 8;
    3 const MAX_TEAMS = 4;
    41const MAX_HEADINGTITLE = 8;
    52
    63// const for filtering long collective headings
    74const LONG_HEADING_WIDTH = 250;
    85// Vertical size of player box
     
    4340 * Select active panel
    4441 * @param panelNumber Number of panel, which should get active state (integer)
    4542 */
    4643function selectPanel(panelNumber)
    4744{
     45    if (!g_Settings)
     46        return;
     47
    4848    var panelNames = [ 'scorePanel', 'buildingsPanel', 'unitsPanel', 'resourcesPanel', 'marketPanel', 'miscPanel'];
    4949
    5050    function adjustTabDividers(tabSize)
    5151    {
    5252        var leftSpacer = Engine.GetGUIObjectByName("tabDividerLeft");
     
    130130        teamCounterFn(panelInfo.counters);
    131131}
    132132
    133133function init(data)
    134134{
     135    if (!g_Settings)
     136        return;
     137
    135138    updateObjectPlayerPosition();
    136139    g_GameData = data;
    137140
    138     // Map
    139     var mapDisplayType = translate("Scenario");
    140 
    141141    Engine.GetGUIObjectByName("timeElapsed").caption = sprintf(translate("Game time elapsed: %(time)s"), { time: timeToString(data.timeElapsed) });
    142142
    143143    Engine.GetGUIObjectByName("summaryText").caption = data.gameResult;
    144144
    145     // This is only defined for random maps
    146     if (data.mapSettings.Size)
    147     {
    148         // load the map sizes from the JSON file
    149         var mapSizes = initMapSizes();
    150 
    151         // retrieve the index of the map size
    152         for (var mapSizeIndex in mapSizes.tiles)
    153         {
    154             if (mapSizes.tiles[mapSizeIndex] == data.mapSettings.Size)
    155             {
    156                 mapDisplayType = mapSizes.names[mapSizeIndex];
    157                 break;
    158             }
    159         }
    160     }
    161 
    162     Engine.GetGUIObjectByName("mapName").caption = sprintf(translate("%(mapName)s - %(mapType)s"), { mapName: translate(data.mapSettings.Name), mapType: mapDisplayType});
     145    var mapDisplayType = data.mapSettings.mapType == "random" ? translateMapSize(data.mapSettings.Size) : translateMapType(data.mapSettings.mapType);
     146    Engine.GetGUIObjectByName("mapName").caption = sprintf(translate("%(mapName)s - %(mapType)s"),
     147            { "mapName": translate(data.mapSettings.Name), "mapType": mapDisplayType });
    163148
    164149    // Panels
    165150    g_MaxPlayers = data.playerStates.length - 1;
    166151
    167152    if (data.mapSettings.LockTeams) // teams ARE locked
  • binaries/data/mods/public/gui/summary/summary.xml

     
    88
    99<objects>
    1010    <script file="gui/common/functions_global_object.js"/>
    1111    <script file="gui/common/functions_civinfo.js"/>
    1212    <script file="gui/common/functions_utility.js"/>
     13    <script file="gui/common/settings.js"/>
    1314    <script file="gui/summary/counters.js"/>
    1415    <script file="gui/summary/layout.js"/>
    1516    <script file="gui/summary/summary.js"/>
    1617
    1718    <object type="image"
  • binaries/data/mods/public/l10n/messages.json

     
    451451                }
    452452            },
    453453            {
    454454                "extractor": "json",
    455455                "filemasks": [
    456                     "simulation/data/game_speeds.json",
    457                     "simulation/data/player_defaults.json"
     456                    "simulation/data/settings/AIDifficulties.json"
    458457                ],
    459458                "options": {
    460                     "keywords": [
    461                         "Name"
    462                     ]
     459                    "keywords": ["Title"],
     460                    "context": "aiDiff"
    463461                }
    464462            },
    465463            {
    466464                "extractor": "json",
    467465                "filemasks": [
    468                     "simulation/data/map_sizes.json"
     466                    "simulation/data/settings/Ceasefire.json"
    469467                ],
    470468                "options": {
    471                     "keywords": [
    472                         "Name",
    473                         "LongName"
    474                     ]
     469                    "keywords": ["Title"],
     470                    "context": "ceasefire"
     471                }
     472            },
     473            {
     474                "extractor": "json",
     475                "filemasks": [
     476                    "simulation/data/settings/GameSpeeds.json",
     477                    "simulation/data/settings/PopulationCapacity.json"
     478                ],
     479                "options": {
     480                    "keywords": ["Title"]
     481                }
     482            },
     483            {
     484                "extractor": "json",
     485                "filemasks": [
     486                    "simulation/data/settings/GameTypes/*.json",
     487                ],
     488                "options": {
     489                    "keywords": ["Title", "Description"]
     490                }
     491            },
     492            {
     493                "extractor": "json",
     494                "filemasks": [
     495                    "simulation/data/settings/PlayerDefaults.json"
     496                ],
     497                "options": {
     498                    "keywords": ["Name"]
     499                }
     500            },
     501            {
     502                "extractor": "json",
     503                "filemasks": [
     504                    "simulation/data/settings/MapSizes.json"
     505                ],
     506                "options": {
     507                    "keywords": ["Name", "LongName"]
     508                }
     509            },
     510            {
     511                "extractor": "json",
     512                "filemasks": [
     513                    "simulation/data/settings/MapTypes.json"
     514                ],
     515                "options": {
     516                    "keywords": ["Title"],
     517                    "context": "map"
     518                }
     519            },
     520            {
     521                "extractor": "json",
     522                "filemasks": [
     523                    "simulation/data/settings/StartingResources.json"
     524                ],
     525                "options": {
     526                    "keywords": ["Title"],
     527                    "context": "startingResources"
    475528                }
    476529            },
    477530            {
    478531                "extractor": "json",
    479532                "filemasks": [
  • binaries/data/mods/public/simulation/data/game_speeds.json

     
    1 {
    2     "Speeds":
    3     [
    4         {
    5             "Name": "Turtle (0.1x)",
    6             "Speed": 0.10
    7         },
    8         {
    9             "Name": "Slow (0.25x)",
    10             "Speed": 0.25
    11         },
    12         {
    13             "Name": "Leisurely (0.5x)",
    14             "Speed": 0.50
    15         },
    16         {
    17             "Name": "Relaxed (0.75x)",
    18             "Speed": 0.75
    19         },
    20         {
    21             "Name": "Normal (1x)",
    22             "Speed": 1.0,
    23             "Default": true
    24         },
    25         {
    26             "Name": "Fast (1.25x)",
    27             "Speed": 1.25
    28         },
    29         {
    30             "Name": "Very Fast (1.5x)",
    31             "Speed": 1.5
    32         },
    33         {
    34             "Name": "Insane (2x)",
    35             "Speed": 2.0
    36         }
    37     ]
    38 }
  • binaries/data/mods/public/simulation/data/map_sizes.json

     
    1 {
    2     "Sizes":
    3     [
    4         {
    5             "Name": "Tiny",
    6             "LongName": "Tiny",
    7             "Tiles": 128
    8         },
    9         {
    10             "Name": "Small",
    11             "LongName": "Small (2 players)",
    12             "Tiles": 192
    13         },
    14         {
    15             "Name": "Medium",
    16             "LongName": "Medium (3 players)",
    17             "Tiles": 256,
    18             "Default": true
    19         },
    20         {
    21             "Name": "Normal",
    22             "LongName": "Normal (4 players)",
    23             "Tiles": 320
    24         },
    25         {
    26             "Name": "Large",
    27             "LongName": "Large (6 players)",
    28             "Tiles": 384
    29         },
    30         {
    31             "Name": "Very Large",
    32             "LongName": "Very Large (8 players)",
    33             "Tiles": 448
    34         },
    35         {
    36             "Name": "Giant",
    37             "LongName": "Giant",
    38             "Tiles": 512
    39         }
    40     ]
    41 }
  • binaries/data/mods/public/simulation/data/player_defaults.json

     
    1 {
    2     "PlayerData":
    3     [
    4         {
    5             "Name": "Gaia",
    6             "Civ": "gaia",
    7             "Color": { "r": 255, "g": 255, "b": 255 },
    8             "AI": "",
    9             "AIDiff": 3
    10         },
    11         {
    12             "Name": "Player 1",
    13             "Civ": "athen",
    14             "Color": { "r": 46, "g": 46, "b": 200 },
    15             "AI": "",
    16             "AIDiff": 3
    17         },
    18         {
    19             "Name": "Player 2",
    20             "Civ": "cart",
    21             "Color": { "r": 150, "g": 20, "b": 20 },
    22             "AI": "petra",
    23             "AIDiff": 3
    24         },
    25         {
    26             "Name": "Player 3",
    27             "Civ": "gaul",
    28             "Color": { "r": 50, "g": 165, "b": 5 },
    29             "AI": "petra",
    30             "AIDiff": 3
    31         },
    32         {
    33             "Name": "Player 4",
    34             "Civ": "iber",
    35             "Color": { "r": 230, "g": 230, "b": 75 },
    36             "AI": "petra",
    37             "AIDiff": 3
    38         },
    39         {
    40             "Name": "Player 5",
    41             "Civ": "mace",
    42             "Color": { "r": 50, "g": 170, "b": 170 },
    43             "AI": "petra",
    44             "AIDiff": 3
    45         },
    46         {
    47             "Name": "Player 6",
    48             "Civ": "maur",
    49             "Color": { "r": 160, "g": 80, "b": 200 },
    50             "AI": "petra",
    51             "AIDiff": 3
    52         },
    53         {
    54             "Name": "Player 7",
    55             "Civ": "pers",
    56             "Color": { "r": 235, "g": 120, "b": 20 },
    57             "AI": "petra",
    58             "AIDiff": 3
    59         },
    60         {
    61             "Name": "Player 8",
    62             "Civ": "rome",
    63             "Color": { "r": 64, "g": 64, "b": 64 },
    64             "AI": "petra",
    65             "AIDiff": 3
    66         }
    67     ]
    68 }
  • binaries/data/mods/public/simulation/data/settings/AIDifficulties.json

     
     1{
     2    "TranslatedKeys": { "Title": "aiDiff" },
     3    "AIDifficulties":
     4    [
     5        {
     6            "Name": "sandbox",
     7            "Title": "Sandbox"
     8        },
     9        {
     10            "Name": "very easy",
     11            "Title": "Very Easy"
     12        },
     13        {
     14            "Name": "easy",
     15            "Title": "Easy"
     16        },
     17        {
     18            "Name": "medium",
     19            "Title": "Medium",
     20            "Default": true
     21        },
     22        {
     23            "Name": "hard",
     24            "Title": "Hard"
     25        },
     26        {
     27            "Name": "very hard",
     28            "Title": "Very Hard"
     29        }
     30    ]
     31}
  • binaries/data/mods/public/simulation/data/settings/Ceasefire.json

     
     1{
     2    "TranslatedKeys": { "Title": "ceasefire" },
     3    "Ceasefire":
     4    [
     5        {
     6            "Duration": 0,
     7            "Title": "No ceasefire",
     8            "Default": true
     9        },
     10        {
     11            "Duration": 1,
     12            "Title": "1 minute"
     13        },
     14        {
     15            "Duration": 2,
     16            "Title": "2 minutes"
     17        },
     18        {
     19            "Duration": 3,
     20            "Title": "3 minutes"
     21        },
     22        {
     23            "Duration": 4,
     24            "Title": "4 minutes"
     25        },
     26        {
     27            "Duration": 5,
     28            "Title": "5 minutes"
     29        },
     30        {
     31            "Duration": 10,
     32            "Title": "10 minutes"
     33        },
     34        {
     35            "Duration": 15,
     36            "Title": "15 minutes"
     37        },
     38        {
     39            "Duration": 20,
     40            "Title": "20 minutes"
     41        },
     42        {
     43            "Duration": 30,
     44            "Title": "30 minutes"
     45        },
     46        {
     47            "Duration": 45,
     48            "Title": "45 minutes"
     49        },
     50        {
     51            "Duration": 60,
     52            "Title": "60 minutes"
     53        }
     54    ]
     55}
  • binaries/data/mods/public/simulation/data/settings/GameSpeeds.json

     
     1{
     2    "TranslatedKeys": ["Title"],
     3    "GameSpeeds":
     4    [
     5        {
     6            "Speed": 0.10,
     7            "Title": "Turtle (0.1x)"
     8        },
     9        {
     10            "Speed": 0.25,
     11            "Title": "Slow (0.25x)"
     12        },
     13        {
     14            "Speed": 0.50,
     15            "Title": "Leisurely (0.5x)"
     16        },
     17        {
     18            "Speed": 0.75,
     19            "Title": "Relaxed (0.75x)"
     20        },
     21        {
     22            "Speed": 1.0,
     23            "Title": "Normal (1x)",
     24            "Default": true
     25        },
     26        {
     27            "Speed": 1.25,
     28            "Title": "Fast (1.25x)"
     29        },
     30        {
     31            "Speed": 1.5,
     32            "Title": "Very Fast (1.5x)"
     33        },
     34        {
     35            "Speed": 2.0,
     36            "Title": "Insane (2x)"
     37        }
     38    ]
     39}
  • binaries/data/mods/public/simulation/data/settings/GameTypes/Conquest.json

     
     1{
     2    "TranslatedKeys" : ["Title", "Description"],
     3    "Conquest" :
     4    {
     5        "Name": "conquest",
     6        "Title": "Conquest",
     7        "Description": "Defeat all opponents",
     8        "Scripts":
     9        [
     10            "scripts/TriggerHelper.js",
     11            "scripts/ConquestCommon.js",
     12            "scripts/Conquest.js"
     13        ],
     14        "Default": true
     15    }
     16}
  • binaries/data/mods/public/simulation/data/settings/GameTypes/ConquestStructures.json

     
     1{
     2    "TranslatedKeys" : ["Title", "Description"],
     3    "ConquestStructures" :
     4    {
     5        "Name": "conquestStructures",
     6        "Title": "Conquest Structures",
     7        "Description": "Destroy all structures of enemies",
     8        "Scripts":
     9        [
     10            "scripts/TriggerHelper.js",
     11            "scripts/ConquestCommon.js",
     12            "scripts/ConquestStructures.js"
     13        ]
     14    }
     15}
  • binaries/data/mods/public/simulation/data/settings/GameTypes/ConquestUnits.json

     
     1{
     2    "TranslatedKeys" : ["Title", "Description"],
     3    "ConquestUnits" :
     4    {
     5        "Name": "conquestUnits",
     6        "Title": "Conquest Units",
     7        "Description": "Kill all enemy units",
     8        "Scripts":
     9        [
     10            "scripts/TriggerHelper.js",
     11            "scripts/ConquestCommon.js",
     12            "scripts/ConquestUnits.js"
     13        ]
     14    }
     15}
  • binaries/data/mods/public/simulation/data/settings/GameTypes/Endless.json

     
     1{
     2    "TranslatedKeys" : ["Title", "Description"],
     3    "Endless" :
     4    {
     5        "Name": "endless",
     6        "Title": "None",
     7        "Description": "Endless Game",
     8        "Scripts": []
     9    }
     10}
  • binaries/data/mods/public/simulation/data/settings/GameTypes/Wonder.json

     
     1{
     2    "TranslatedKeys" : ["Title", "Description"],
     3    "Wonder" :
     4    {
     5        "Name": "wonder",
     6        "Title": "Wonder",
     7        "Description": "Build and protect a wonder to win",
     8        "Scripts":
     9        [
     10            "scripts/TriggerHelper.js",
     11            "scripts/ConquestCommon.js",
     12            "scripts/Conquest.js",
     13            "scripts/WonderVictory.js"
     14        ]
     15    }
     16}
  • binaries/data/mods/public/simulation/data/settings/MapSizes.json

     
     1{
     2    "TranslatedKeys": ["Name", "LongName"],
     3    "MapSizes":
     4    [
     5        {
     6            "Tiles": 128,
     7            "Name": "Tiny",
     8            "LongName": "Tiny"
     9        },
     10        {
     11            "Tiles": 192,
     12            "Name": "Small",
     13            "LongName": "Small (2 players)"
     14        },
     15        {
     16            "Tiles": 256,
     17            "Name": "Medium",
     18            "LongName": "Medium (3 players)",
     19            "Default": true
     20        },
     21        {
     22            "Tiles": 320,
     23            "Name": "Normal",
     24            "LongName": "Normal (4 players)"
     25        },
     26        {
     27            "Tiles": 384,
     28            "Name": "Large",
     29            "LongName": "Large (6 players)"
     30        },
     31        {
     32            "Tiles": 448,
     33            "Name": "Very Large",
     34            "LongName": "Very Large (8 players)"
     35        },
     36        {
     37            "Tiles": 512,
     38            "Name": "Giant",
     39            "LongName": "Giant"
     40        }
     41    ]
     42}
  • binaries/data/mods/public/simulation/data/settings/MapTypes.json

     
     1{
     2    "TranslatedKeys": { "Title": "map" },
     3    "MapTypes":
     4    [
     5        {
     6            "Name": "skirmish",
     7            "Title": "Skirmish",
     8            "Default": true
     9        },
     10        {
     11            "Name": "random",
     12            "Title": "Random"
     13        },
     14        {
     15            "Name": "scenario",
     16            "Title": "Scenario"
     17        }
     18    ]
     19}
  • binaries/data/mods/public/simulation/data/settings/PlayerDefaults.json

     
     1{
     2    "TranslatedKeys": ["Name"],
     3    "PlayerDefaults":
     4    [
     5        {
     6            "Name": "Gaia",
     7            "Civ": "gaia",
     8            "Color": { "r": 255, "g": 255, "b": 255 },
     9            "AI": "",
     10            "AIDiff": 3
     11        },
     12        {
     13            "Name": "Player 1",
     14            "Civ": "athen",
     15            "Color": { "r": 46, "g": 46, "b": 200 },
     16            "AI": "",
     17            "AIDiff": 3
     18        },
     19        {
     20            "Name": "Player 2",
     21            "Civ": "cart",
     22            "Color": { "r": 150, "g": 20, "b": 20 },
     23            "AI": "petra",
     24            "AIDiff": 3
     25        },
     26        {
     27            "Name": "Player 3",
     28            "Civ": "gaul",
     29            "Color": { "r": 50, "g": 165, "b": 5 },
     30            "AI": "petra",
     31            "AIDiff": 3
     32        },
     33        {
     34            "Name": "Player 4",
     35            "Civ": "iber",
     36            "Color": { "r": 230, "g": 230, "b": 75 },
     37            "AI": "petra",
     38            "AIDiff": 3
     39        },
     40        {
     41            "Name": "Player 5",
     42            "Civ": "mace",
     43            "Color": { "r": 50, "g": 170, "b": 170 },
     44            "AI": "petra",
     45            "AIDiff": 3
     46        },
     47        {
     48            "Name": "Player 6",
     49            "Civ": "maur",
     50            "Color": { "r": 160, "g": 80, "b": 200 },
     51            "AI": "petra",
     52            "AIDiff": 3
     53        },
     54        {
     55            "Name": "Player 7",
     56            "Civ": "pers",
     57            "Color": { "r": 235, "g": 120, "b": 20 },
     58            "AI": "petra",
     59            "AIDiff": 3
     60        },
     61        {
     62            "Name": "Player 8",
     63            "Civ": "rome",
     64            "Color": { "r": 64, "g": 64, "b": 64 },
     65            "AI": "petra",
     66            "AIDiff": 3
     67        }
     68    ]
     69}
  • binaries/data/mods/public/simulation/data/settings/PlayerLimit.json

     
     1{
     2    "MaxPlayers": 8,
     3    "MaxTeams": 4
     4}
  • binaries/data/mods/public/simulation/data/settings/PopulationCapacity.json

     
     1{
     2    "TranslatedKeys": ["Title"],
     3    "PopulationCapacity":
     4    [
     5        {
     6            "Population": 50,
     7            "Title": "50"
     8        },
     9        {
     10            "Population": 100,
     11            "Title": "100"
     12        },
     13        {
     14            "Population": 150,
     15            "Title": "150"
     16        },
     17        {
     18            "Population": 200,
     19            "Title": "200"
     20        },
     21        {
     22            "Population": 250,
     23            "Title": "250"
     24        },
     25        {
     26            "Population": 300,
     27            "Title": "300",
     28            "Default": true
     29        },
     30        {
     31            "Population": 10000,
     32            "Title": "Unlimited"
     33        }
     34    ]
     35}
  • binaries/data/mods/public/simulation/data/settings/StartingResources.json

     
     1{
     2    "TranslatedKeys": { "Title": "startingResources" },
     3    "StartingResources":
     4    [
     5        {
     6            "Resources": 100,
     7            "Title": "Very Low"
     8        },
     9        {
     10            "Resources": 300,
     11            "Title": "Low",
     12            "Default": true
     13        },
     14        {
     15            "Resources": 500,
     16            "Title": "Medium"
     17        },
     18        {
     19            "Resources": 1000,
     20            "Title": "High"
     21        },
     22        {
     23            "Resources": 3000,
     24            "Title": "Very High"
     25        },
     26        {
     27            "Resources": 50000,
     28            "Title": "Deathmatch"
     29        }
     30    ]
     31}
  • binaries/data/mods/public/simulation/helpers/Player.js

     
    1313    // Default settings
    1414    if (!settings)
    1515        settings = {};
    1616
    1717    // Get default player data
    18     var rawData = Engine.ReadJSONFile("player_defaults.json");
    19     if (!(rawData && rawData.PlayerData))
    20         throw("Player.js: Error reading player_defaults.json");
     18    var rawData = Engine.ReadJSONFile("settings/PlayerDefaults.json");
     19    if (!rawData || !rawData.PlayerDefaults)
     20        throw("Player.js: Error reading PlayerDefaults.json");
    2121
    2222    // Add gaia to simplify iteration
    2323    if (settings.PlayerData && settings.PlayerData[0])
    2424        settings.PlayerData.unshift(null);
    2525
    26     var playerDefaults = rawData.PlayerData;
     26    var playerDefaults = rawData.PlayerDefaults;
    2727    var playerData = settings.PlayerData;
    2828
    2929    // Get player manager
    3030    var cmpPlayerManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager);
    3131    var numPlayers = cmpPlayerManager.GetNumPlayers();
     
    168168            var cmpPlayer = Engine.QueryInterface(cmpPlayerManager.GetPlayerByID(i), IID_Player);
    169169            cmpPlayer.SetLockTeams(true);
    170170        }
    171171
    172172    // Disable the AIIinterface when no AI players are present
    173     if (playerData && !playerData.some(function(v) { return v && v.AI ? true : false; }))
     173    if (playerData && playerData.every(player => !player || !player.AI))
    174174        Engine.QueryInterface(SYSTEM_ENTITY, IID_AIInterface).Disable();
    175175}
    176176
    177177// Get a setting if it exists or return default
    178178function getSetting(settings, defaults, idx, property)
  • source/simulation2/Simulation2.cpp

     
    879879    return file.DecodeUTF8(); // assume it's UTF-8
    880880}
    881881
    882882std::string CSimulation2::GetPlayerDefaults()
    883883{
    884     return ReadJSON(L"simulation/data/player_defaults.json");
     884    return ReadJSON(L"simulation/data/settings/PlayerDefaults.json");
    885885}
    886886
    887887std::string CSimulation2::GetMapSizes()
    888888{
    889     return ReadJSON(L"simulation/data/map_sizes.json");
     889    return ReadJSON(L"simulation/data/settings/MapSizes.json");
    890890}
    891891
    892892std::string CSimulation2::GetAIData()
    893893{
    894894    ScriptInterface& scriptInterface = GetScriptInterface();
  • source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Map/Map.cpp

     
    139139    sizer->Add(Tooltipped(new wxTextCtrl(this, ID_MapDescription, wxEmptyString, wxDefaultPosition, wxSize(-1, 100), wxTE_MULTILINE),
    140140            _("Short description used on the map selection screen")), wxSizerFlags().Expand());
    141141
    142142    sizer->AddSpacer(5);
    143143
     144    // TODO: load from GameTypes.json
    144145    wxArrayString gameTypes;
    145146    gameTypes.Add(_T("conquest"));
     147    gameTypes.Add(_T("conquestStructures"));
     148    gameTypes.Add(_T("conquestUnits"));
    146149    gameTypes.Add(_T("wonder"));
    147150    gameTypes.Add(_T("endless"));
    148151
    149152    wxFlexGridSizer* gridSizer = new wxFlexGridSizer(2, 5, 5);
    150153    gridSizer->AddGrowableCol(1);
     
    368371    // Load the map sizes list
    369372    AtlasMessage::qGetMapSizes qrySizes;
    370373    qrySizes.Post();
    371374    AtObj sizes = AtlasObject::LoadFromJSON(*qrySizes.sizes);
    372375    wxChoice* sizeChoice = wxDynamicCast(FindWindow(ID_RandomSize), wxChoice);
    373     for (AtIter s = sizes["Sizes"]["item"]; s.defined(); ++s)
     376    for (AtIter s = sizes["MapSizes"]["item"]; s.defined(); ++s)
    374377    {
    375378        long tiles = 0;
    376379        wxString(s["Tiles"]).ToLong(&tiles);
    377380        sizeChoice->Append(wxString(s["Name"]), (void*)(intptr_t)tiles);
    378381    }
  • source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Object/Object.cpp

     
    535535    // Get player names
    536536    wxArrayString players;
    537537    AtlasMessage::qGetPlayerDefaults qryPlayers;
    538538    qryPlayers.Post();
    539539    AtObj playerData = AtlasObject::LoadFromJSON(*qryPlayers.defaults);
    540     AtObj playerDefs = *playerData["PlayerData"];
     540    AtObj playerDefs = *playerData["PlayerDefaults"];
    541541    for (AtIter p = playerDefs["item"]; p.defined(); ++p)
    542     {
    543542        players.Add(wxString(p["Name"]));
    544     }
     543
    545544    wxDynamicCast(FindWindow(ID_PlayerSelect), PlayerComboBox)->SetPlayers(players);
    546545
    547546    // Initialise the game with the default settings
    548547    POST_MESSAGE(SetViewParamB, (AtlasMessage::eRenderView::ACTOR, L"wireframe", m_ViewerWireframe));
    549548    POST_MESSAGE(SetViewParamB, (AtlasMessage::eRenderView::ACTOR, L"walk", m_ViewerMove));
  • source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Player/Player.cpp

     
    517517            POST_MESSAGE(LoadPlayerSettings, (true));
    518518            m_MapSettings.NotifyObservers();
    519519        }
    520520    }
    521521
    522     // TODO: we shouldn't hardcode this, but instead dynamically create
    523     //  new player notebook pages on demand; of course the default data
    524     //  will be limited by the entries in player_defaults.json
     522    // TODO: Load value from PlayerLimit.json
    525523    static const size_t MAX_NUM_PLAYERS = 8;
    526524
    527525    bool m_InGUIUpdate;
    528526    AtObj m_PlayerDefaults;
    529527    PlayerNotebook* m_Players;
     
    640638void PlayerSettingsControl::LoadDefaults()
    641639{
    642640    AtlasMessage::qGetPlayerDefaults qryPlayers;
    643641    qryPlayers.Post();
    644642    AtObj playerData = AtlasObject::LoadFromJSON(*qryPlayers.defaults);
    645     m_PlayerDefaults = *playerData["PlayerData"];
     643    m_PlayerDefaults = *playerData["PlayerDefaults"];
    646644}
    647645
    648646void PlayerSettingsControl::ReadFromEngine()
    649647{
    650648    AtlasMessage::qGetMapSettings qry;
  • source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Terrain/Terrain.cpp

     
    284284
    285285    // Load the map sizes list
    286286    AtlasMessage::qGetMapSizes qrySizes;
    287287    qrySizes.Post();
    288288    AtObj sizes = AtlasObject::LoadFromJSON(*qrySizes.sizes);
    289     for (AtIter s = sizes["Sizes"]["item"]; s.defined(); ++s)
     289    for (AtIter s = sizes["MapSizes"]["item"]; s.defined(); ++s)
    290290    {
    291291        long tiles = 0;
    292292        wxString(s["Tiles"]).ToLong(&tiles);
    293293        sizeNames.Add(wxString(s["Name"]));
    294294        sizeTiles.push_back((size_t)tiles);
  • source/tools/i18n/extractors/extractors.py

     
    303303
    304304    def __init__(self, directoryPath=None, filemasks=[], options={}):
    305305        super(json, self).__init__(directoryPath, filemasks, options)
    306306        self.breadcrumbs = []
    307307        self.keywords = self.options.get("keywords", {})
     308        self.context = self.options.get("context", None)
    308309
    309310    def setOptions(self, options):
    310311        self.options = options
    311312        self.keywords = self.options.get("keywords", {})
     313        self.context = self.options.get("context", None)
    312314
    313315    @staticmethod
    314316    def formatBreadcrumbs(breadcrumbs):
    315317        firstPiece = breadcrumbs[0]
    316318        if isinstance(firstPiece, int): outputString = "[" + str(firstPiece) + "]"
     
    321323        return outputString
    322324
    323325    def extractFromFile(self, filepath):
    324326        with codecs.open(filepath, "r", 'utf-8') as fileObject:
    325327            for message, breadcrumbs in self.extractFromString(fileObject.read()):
    326                 yield message, None, None, self.formatBreadcrumbs(breadcrumbs), -1, []
     328                yield message, None, self.context, self.formatBreadcrumbs(breadcrumbs), -1, []
    327329
    328330    def extractFromString(self, string):
    329331        self.breadcrumbs = []
    330332        jsonDocument = jsonParser.loads(string)
    331333        if isinstance(jsonDocument, list):