1
0
forked from 0ad/0ad

This was SVN commit r9610.

This commit is contained in:
historic_bruno 2011-06-09 23:52:29 +00:00
parent 0c803f99e8
commit 4a3230a870
5 changed files with 106 additions and 36 deletions

View File

@ -162,6 +162,45 @@ function initPlayerDefaults()
// ==================================================================== // ====================================================================
// Load map size data
function initMapSizes()
{
var filename = "simulation/data/map_sizes.json";
var sizes = {
names: [],
tiles: [],
default: 0
};
var rawData = readFile(filename);
if (!rawData)
error("Failed to read map sizes file: "+filename);
try
{ // Catch nasty errors from JSON parsing
// TODO: Need more info from the parser on why it failed: line number, position, etc!
var data = JSON.parse(rawData);
if (!data || !data.Sizes)
error("Failed to parse map sizes in: "+filename+" (check for valid JSON data)");
for (var i = 0; i < data.Sizes.length; ++i)
{
sizes.names.push(data.Sizes[i].LongName);
sizes.tiles.push(data.Sizes[i].Tiles);
if (data.Sizes[i].Default)
sizes.default = i;
}
}
catch(err)
{
error(err.toString()+": parsing map sizes in "+filename);
}
return sizes;
}
// ====================================================================
// Convert integer color values to string (for use in GUI objects) // Convert integer color values to string (for use in GUI objects)
function iColorToString(color) function iColorToString(color)
{ {

View File

@ -1,10 +1,6 @@
//////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////
// Constants // Constants
// TODO: Move these into common location (other scripts may need) // TODO: Move these somewhere like simulation\data\game_types.json, Atlas needs them too
const MAP_SIZES_TEXT = ["Tiny (2 player)", "Small (3 player)", "Medium (4 player)", "Normal (6 player)", "Large (8 player)", "Very Large", "Giant"];
const MAP_SIZES_DATA = [128, 192, 256, 320, 384, 448, 512];
const MAP_SIZES_DEFAULTIDX = 2;
const VICTORY_TEXT = ["Conquest", "None"]; const VICTORY_TEXT = ["Conquest", "None"];
const VICTORY_DATA = ["conquest", "endless"]; const VICTORY_DATA = ["conquest", "endless"];
const VICTORY_DEFAULTIDX = 0; const VICTORY_DEFAULTIDX = 0;
@ -32,6 +28,8 @@ var g_GameAttributes = {
settings: {} settings: {}
}; };
var g_MapSizes = {};
var g_AIs = []; var g_AIs = [];
var g_ChatMessages = []; var g_ChatMessages = [];
@ -85,6 +83,8 @@ function initMain()
g_DefaultPlayerData = initPlayerDefaults(); g_DefaultPlayerData = initPlayerDefaults();
g_DefaultPlayerData.shift(); g_DefaultPlayerData.shift();
g_MapSizes = initMapSizes();
// Init civs // Init civs
initCivNameList(); initCivNameList();
@ -138,13 +138,13 @@ function initMain()
victoryConditions.selected = VICTORY_DEFAULTIDX; victoryConditions.selected = VICTORY_DEFAULTIDX;
var mapSize = getGUIObjectByName("mapSize"); var mapSize = getGUIObjectByName("mapSize");
mapSize.list = MAP_SIZES_TEXT; mapSize.list = g_MapSizes.names;
mapSize.list_data = MAP_SIZES_DATA; mapSize.list_data = g_MapSizes.tiles;
mapSize.onSelectionChange = function() mapSize.onSelectionChange = function()
{ // Update attributes so other players can see change { // Update attributes so other players can see change
if (this.selected != -1) if (this.selected != -1)
{ {
g_GameAttributes.settings.Size = MAP_SIZES_DATA[this.selected]; g_GameAttributes.settings.Size = g_MapSizes.tiles[this.selected];
} }
if (!g_IsInGuiUpdate) if (!g_IsInGuiUpdate)
@ -768,7 +768,7 @@ function onGameAttributesChange()
var mapSizeText = getGUIObjectByName("mapSizeText"); var mapSizeText = getGUIObjectByName("mapSizeText");
var numPlayersBox = getGUIObjectByName("numPlayersBox"); var numPlayersBox = getGUIObjectByName("numPlayersBox");
var sizeIdx = (MAP_SIZES_DATA.indexOf(mapSettings.Size) != -1 ? MAP_SIZES_DATA.indexOf(mapSettings.Size) : MAP_SIZES_DEFAULTIDX); var sizeIdx = (g_MapSizes.tiles.indexOf(mapSettings.Size) != -1 ? g_MapSizes.tiles.indexOf(mapSettings.Size) : g_MapSizes.default);
var victoryIdx = (VICTORY_DATA.indexOf(mapSettings.GameType) != -1 ? VICTORY_DATA.indexOf(mapSettings.GameType) : VICTORY_DEFAULTIDX); var victoryIdx = (VICTORY_DATA.indexOf(mapSettings.GameType) != -1 ? VICTORY_DATA.indexOf(mapSettings.GameType) : VICTORY_DEFAULTIDX);
// Handle map type specific logic // Handle map type specific logic
@ -796,7 +796,7 @@ function onGameAttributesChange()
} }
else else
{ // Client { // Client
mapSizeText.caption = "Map size: " + MAP_SIZES_TEXT[sizeIdx]; mapSizeText.caption = "Map size: " + g_MapSizes.names[sizeIdx];
revealMapText.caption = "Reveal map: " + (mapSettings.RevealMap ? "Yes" : "No"); revealMapText.caption = "Reveal map: " + (mapSettings.RevealMap ? "Yes" : "No");
victoryConditionText.caption = "Victory condition: " + VICTORY_TEXT[victoryIdx]; victoryConditionText.caption = "Victory condition: " + VICTORY_TEXT[victoryIdx];
lockTeamsText.caption = "Teams locked: " + (mapSettings.LockTeams === undefined || mapSettings.LockTeams ? "Yes" : "No"); lockTeamsText.caption = "Teams locked: " + (mapSettings.LockTeams === undefined || mapSettings.LockTeams ? "Yes" : "No");

View File

@ -0,0 +1,41 @@
{
"Sizes":
[
{
"Name": "Tiny",
"LongName": "Tiny (2 player)",
"Tiles": 128
},
{
"Name": "Small",
"LongName": "Small (3 player)",
"Tiles": 192
},
{
"Name": "Medium",
"LongName": "Medium (4 player)",
"Tiles": 256,
"Default": true
},
{
"Name": "Normal",
"LongName": "Normal (6 player)",
"Tiles": 320
},
{
"Name": "Large",
"LongName": "Large (8 player)",
"Tiles": 384
},
{
"Name": "Very Large",
"LongName": "Very Large",
"Tiles": 448
},
{
"Name": "Giant",
"LongName": "Giant",
"Tiles": 512
}
]
}

View File

@ -25,23 +25,20 @@
</attachpoints> </attachpoints>
<animations> <animations>
<item>idle </item>
<item>attack1 </item> <item>walk </item>
<item>attack2 </item> <item>run </item>
<item>build </item> <item>melee </item>
<item>corpse </item>
<item>death </item> <item>death </item>
<item>build </item>
<item>gather_fruit </item> <item>gather_fruit </item>
<item>gather_grain </item> <item>gather_grain </item>
<item>gather_wood </item> <item>gather_meat </item>
<item>gather_stone</item> <item>gather_tree </item>
<item>gather_metal</item> <item>gather_rock </item>
<item>gather_ore </item>
<item>gather_ruins </item> <item>gather_ruins </item>
<item>gather_treasure</item> <item>gather_treasure</item>
<item>idle </item>
<item>melee </item>
<item>run </item>
<item>walk </item>
</animations> </animations>
<playercolours> <playercolours>
@ -56,14 +53,4 @@
<colour name="Player 8" rgb="64 64 64" buttontext="255 255 255"/> <colour name="Player 8" rgb="64 64 64" buttontext="255 255 255"/>
</playercolours> </playercolours>
<mapsizes>
<size name="Tiny" tiles="128"/>
<size name="Small" tiles="192"/>
<size name="Medium" tiles="256"/>
<size name="Normal" tiles="320"/>
<size name="Large" tiles="384"/>
<size name="Very Large" tiles="448"/>
<size name="Giant" tiles="512"/>
</mapsizes>
</lists> </lists>

BIN
binaries/data/tools/atlas/toolbar/player.png (Stored with Git LFS) Normal file

Binary file not shown.