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
|
|
3 | 3 | const DEFAULT_NETWORKED_MAP = "Median Oasis"; |
4 | 4 | const DEFAULT_OFFLINE_MAP = "Oasis"; |
5 | 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
6 | 12 | // TODO: Move these somewhere like simulation\data\game_types.json, Atlas needs them too |
7 | 13 | const VICTORY_TEXT = ["Conquest", "None"]; |
8 | 14 | const VICTORY_DATA = ["conquest", "endless"]; |
… |
… |
function initCivNameList()
|
387 | 393 | var civListNames = [ civ.name for each (civ in civList) ]; |
388 | 394 | var civListCodes = [ civ.code for each (civ in civList) ]; |
389 | 395 | |
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.); |
393 | 399 | |
394 | 400 | // Update the dropdowns |
395 | 401 | for (var i = 0; i < MAX_PLAYERS; ++i) |
… |
… |
function launchGame()
|
709 | 715 | { |
710 | 716 | return; |
711 | 717 | } |
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 | |
713 | 731 | if (g_IsNetworked) |
714 | 732 | { |
715 | 733 | Engine.SetNetworkGameAttributes(g_GameAttributes); |
… |
… |
function launchGame()
|
718 | 736 | else |
719 | 737 | { |
720 | 738 | // Find the player ID which the user has been assigned to |
721 | | var numPlayers = g_GameAttributes.settings.PlayerData.length; |
722 | 739 | var playerID = -1; |
723 | 740 | for (var i = 0; i < numPlayers; ++i) |
724 | 741 | { |
… |
… |
function launchGame()
|
727 | 744 | { |
728 | 745 | playerID = i+1; |
729 | 746 | } |
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 | | } |
737 | 747 | } |
738 | 748 | // Remove extra player data |
739 | 749 | g_GameAttributes.settings.PlayerData = g_GameAttributes.settings.PlayerData.slice(0, numPlayers); |
… |
… |
function onGameAttributesChange()
|
906 | 916 | pTeamText.hidden = false; |
907 | 917 | pTeam.hidden = true; |
908 | 918 | |
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); |
911 | 922 | pTeamText.caption = (team !== undefined && team >= 0) ? team+1 : "-"; |
912 | 923 | } |
913 | 924 | else if (g_GameAttributes.mapType == "random") |
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
|
|
9 | 9 | }, |
10 | 10 | { |
11 | 11 | "Name": "Player 1", |
12 | | "Civ": "hele", |
| 12 | "Civ": "", |
13 | 13 | "Colour": { "r": 80, "g": 80, "b": 200 }, |
14 | 14 | "AI": "" |
15 | 15 | }, |
16 | 16 | { |
17 | 17 | "Name": "Player 2", |
18 | | "Civ": "hele", |
| 18 | "Civ": "", |
19 | 19 | "Colour": { "r": 150, "g": 20, "b": 20 }, |
20 | 20 | "AI": "qbot" |
21 | 21 | }, |
22 | 22 | { |
23 | 23 | "Name": "Player 3", |
24 | | "Civ": "hele", |
| 24 | "Civ": "", |
25 | 25 | "Colour": { "r": 50, "g": 165, "b": 5 }, |
26 | 26 | "AI": "qbot" |
27 | 27 | }, |
28 | 28 | { |
29 | 29 | "Name": "Player 4", |
30 | | "Civ": "hele", |
| 30 | "Civ": "", |
31 | 31 | "Colour": { "r": 230, "g": 230, "b": 75 }, |
32 | 32 | "AI": "qbot" |
33 | 33 | }, |
34 | 34 | { |
35 | 35 | "Name": "Player 5", |
36 | | "Civ": "hele", |
| 36 | "Civ": "", |
37 | 37 | "Colour": { "r": 50, "g": 170, "b": 170 }, |
38 | 38 | "AI": "qbot" |
39 | 39 | }, |
40 | 40 | { |
41 | 41 | "Name": "Player 6", |
42 | | "Civ": "hele", |
| 42 | "Civ": "", |
43 | 43 | "Colour": { "r": 160, "g": 80, "b": 200 }, |
44 | 44 | "AI": "qbot" |
45 | 45 | }, |
46 | 46 | { |
47 | 47 | "Name": "Player 7", |
48 | | "Civ": "hele", |
| 48 | "Civ": "", |
49 | 49 | "Colour": { "r": 235, "g": 120, "b": 20 }, |
50 | 50 | "AI": "qbot" |
51 | 51 | }, |
52 | 52 | { |
53 | 53 | "Name": "Player 8", |
54 | | "Civ": "hele", |
| 54 | "Civ": "", |
55 | 55 | "Colour": { "r": 64, "g": 64, "b": 64 }, |
56 | 56 | "AI": "qbot" |
57 | 57 | } |