Ticket #1082: 0002-random-civ-color-default-first-nwpath.patch

File 0002-random-civ-color-default-first-nwpath.patch, 5.2 KB (added by Deepak Antony, 13 years ago)

Random Civ Option - put it as the first option, text color changed to orange, works on client UI, works on multiplayer and made it the default civ

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

    From 8255e12dad3718899d24c9c1ed27f6434698cfd1 Mon Sep 17 00:00:00 2001
    From: Deepak Antony <deepakantony@gmail.com>
    Date: Mon, 9 Jan 2012 23:59:37 -0800
    Subject: [PATCH 2/2] changed random text color to orange; made random the
     default choice of civ; made random the first option in
     the dropdown; random civ will work withe multiplayer
     path
    
    ---
     .../data/mods/public/gui/gamesetup/gamesetup.js    |   39 +++++++++++++-------
     .../public/simulation/data/player_defaults.json    |   16 ++++----
     2 files changed, 33 insertions(+), 22 deletions(-)
    
    diff --git a/binaries/data/mods/public/gui/gamesetup/gamesetup.js b/binaries/data/mods/public/gui/gamesetup/gamesetup.js
    index b71c678..ee2f95b 100644
    a b  
    33const DEFAULT_NETWORKED_MAP = "Median Oasis";
    44const DEFAULT_OFFLINE_MAP = "Oasis";
    55
     6
     7
     8
     9
     10
     11
    612// TODO: Move these somewhere like simulation\data\game_types.json, Atlas needs them too
    713const VICTORY_TEXT = ["Conquest", "None"];
    814const VICTORY_DATA = ["conquest", "endless"];
    function initCivNameList()  
    387393    var civListNames = [ civ.name for each (civ in civList) ];
    388394    var civListCodes = [ civ.code for each (civ in civList) ];
    389395   
    390     // Add random to the end of the list.
    391     civListNames.push("[color=\"140 140 140 255\"]Random");
    392     civListCodes.push("Random");
     396    // Add random to the
     397    civListNames.);
     398    civListCodes.);
    393399
    394400    // Update the dropdowns
    395401    for (var i = 0; i < MAX_PLAYERS; ++i)
    function launchGame()  
    709715    {
    710716        return;
    711717    }
    712 
     718   
     719    var numPlayers = g_GameAttributes.settings.PlayerData.length;
     720    // We should assign a proper civilization if "random" was selected
     721    for (var i = 0; i < numPlayers; ++i)
     722    {
     723        var civBox = getGUIObjectByName("playerCiv["+i+"]");
     724        if (civBox.list_data[civBox.selected] == RANDOM_CIV.Code)
     725        {
     726            // "Random" is always the first element; if not this logic has to change
     727            g_GameAttributes.settings.PlayerData[i].Civ = civBox.list_data[Math.floor(Math.random()*(civBox.list_data.length-1))+1];
     728        }
     729    }
     730   
    713731    if (g_IsNetworked)
    714732    {
    715733        Engine.SetNetworkGameAttributes(g_GameAttributes);
    function launchGame()  
    718736    else
    719737    {
    720738        // Find the player ID which the user has been assigned to
    721         var numPlayers = g_GameAttributes.settings.PlayerData.length;
    722739        var playerID = -1;
    723740        for (var i = 0; i < numPlayers; ++i)
    724741        {
    function launchGame()  
    727744            {
    728745                playerID = i+1;
    729746            }
    730             // while we are at it, we should assign a proper civilization if "Random" was selected
    731             var civBox = getGUIObjectByName("playerCiv["+i+"]");
    732             if (civBox.list_data[civBox.selected] == "Random")
    733             {
    734                 // "Random" is always the last element; if not this logic has to change
    735                 g_GameAttributes.settings.PlayerData[i].Civ = civBox.list_data[Math.floor(Math.random()*(civBox.list_data.length-1))];
    736             }
    737747        }
    738748        // Remove extra player data
    739749        g_GameAttributes.settings.PlayerData = g_GameAttributes.settings.PlayerData.slice(0, numPlayers);
    function onGameAttributesChange()  
    906916                pTeamText.hidden = false;
    907917                pTeam.hidden = true;
    908918
    909                 // Set text values
    910                 pCivText.caption = g_CivData[civ].Name;
     919                // Set text values.
     920                // Since g_CivData only contains valid civilizations, take care of the case when "Random" is selected.
     921                pCivText.caption = (g_CivData[civ] ? g_CivData[civ].Name : RANDOM_CIV.Name);
    911922                pTeamText.caption = (team !== undefined && team >= 0) ? team+1 : "-";
    912923            }
    913924            else if (g_GameAttributes.mapType == "random")
  • binaries/data/mods/public/simulation/data/player_defaults.json

    diff --git a/binaries/data/mods/public/simulation/data/player_defaults.json b/binaries/data/mods/public/simulation/data/player_defaults.json
    index 74b710b..21ed23f 100644
    a b  
    99        },
    1010        {
    1111            "Name": "Player 1",
    12             "Civ": "hele",
     12            "Civ": "",
    1313            "Colour": { "r": 80, "g": 80, "b": 200 },
    1414            "AI": ""
    1515        },
    1616        {
    1717            "Name": "Player 2",
    18             "Civ": "hele",
     18            "Civ": "",
    1919            "Colour": { "r": 150, "g": 20, "b": 20 },
    2020            "AI": "qbot"
    2121        },
    2222        {
    2323            "Name": "Player 3",
    24             "Civ": "hele",
     24            "Civ": "",
    2525            "Colour": { "r": 50, "g": 165, "b": 5 },
    2626            "AI": "qbot"
    2727        },
    2828        {
    2929            "Name": "Player 4",
    30             "Civ": "hele",
     30            "Civ": "",
    3131            "Colour": { "r": 230, "g": 230, "b": 75 },
    3232            "AI": "qbot"
    3333        },
    3434        {
    3535            "Name": "Player 5",
    36             "Civ": "hele",
     36            "Civ": "",
    3737            "Colour": { "r": 50, "g": 170, "b": 170 },
    3838            "AI": "qbot"
    3939        },
    4040        {
    4141            "Name": "Player 6",
    42             "Civ": "hele",
     42            "Civ": "",
    4343            "Colour": { "r": 160, "g": 80, "b": 200 },
    4444            "AI": "qbot"
    4545        },
    4646        {
    4747            "Name": "Player 7",
    48             "Civ": "hele",
     48            "Civ": "",
    4949            "Colour": { "r": 235, "g": 120, "b": 20 },
    5050            "AI": "qbot"
    5151        },
    5252        {
    5353            "Name": "Player 8",
    54             "Civ": "hele",
     54            "Civ": "",
    5555            "Colour": { "r": 64, "g": 64, "b": 64 },
    5656            "AI": "qbot"
    5757        }