This was SVN commit r9610.
This commit is contained in:
parent
0c803f99e8
commit
4a3230a870
@ -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)
|
||||
function iColorToString(color)
|
||||
{
|
||||
|
@ -1,10 +1,6 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Constants
|
||||
// TODO: Move these into common location (other scripts may need)
|
||||
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;
|
||||
|
||||
// TODO: Move these somewhere like simulation\data\game_types.json, Atlas needs them too
|
||||
const VICTORY_TEXT = ["Conquest", "None"];
|
||||
const VICTORY_DATA = ["conquest", "endless"];
|
||||
const VICTORY_DEFAULTIDX = 0;
|
||||
@ -32,6 +28,8 @@ var g_GameAttributes = {
|
||||
settings: {}
|
||||
};
|
||||
|
||||
var g_MapSizes = {};
|
||||
|
||||
var g_AIs = [];
|
||||
|
||||
var g_ChatMessages = [];
|
||||
@ -84,6 +82,8 @@ function initMain()
|
||||
// Get default player data - remove gaia
|
||||
g_DefaultPlayerData = initPlayerDefaults();
|
||||
g_DefaultPlayerData.shift();
|
||||
|
||||
g_MapSizes = initMapSizes();
|
||||
|
||||
// Init civs
|
||||
initCivNameList();
|
||||
@ -138,13 +138,13 @@ function initMain()
|
||||
victoryConditions.selected = VICTORY_DEFAULTIDX;
|
||||
|
||||
var mapSize = getGUIObjectByName("mapSize");
|
||||
mapSize.list = MAP_SIZES_TEXT;
|
||||
mapSize.list_data = MAP_SIZES_DATA;
|
||||
mapSize.list = g_MapSizes.names;
|
||||
mapSize.list_data = g_MapSizes.tiles;
|
||||
mapSize.onSelectionChange = function()
|
||||
{ // Update attributes so other players can see change
|
||||
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)
|
||||
@ -768,7 +768,7 @@ function onGameAttributesChange()
|
||||
var mapSizeText = getGUIObjectByName("mapSizeText");
|
||||
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);
|
||||
|
||||
// Handle map type specific logic
|
||||
@ -796,7 +796,7 @@ function onGameAttributesChange()
|
||||
}
|
||||
else
|
||||
{ // 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");
|
||||
victoryConditionText.caption = "Victory condition: " + VICTORY_TEXT[victoryIdx];
|
||||
lockTeamsText.caption = "Teams locked: " + (mapSettings.LockTeams === undefined || mapSettings.LockTeams ? "Yes" : "No");
|
||||
|
41
binaries/data/mods/public/simulation/data/map_sizes.json
Normal file
41
binaries/data/mods/public/simulation/data/map_sizes.json
Normal 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
|
||||
}
|
||||
]
|
||||
}
|
@ -25,23 +25,20 @@
|
||||
</attachpoints>
|
||||
|
||||
<animations>
|
||||
|
||||
<item>attack1 </item>
|
||||
<item>attack2 </item>
|
||||
<item>build </item>
|
||||
<item>corpse </item>
|
||||
<item>death </item>
|
||||
<item>gather_fruit</item>
|
||||
<item>gather_grain</item>
|
||||
<item>gather_wood </item>
|
||||
<item>gather_stone</item>
|
||||
<item>gather_metal</item>
|
||||
<item>gather_ruins</item>
|
||||
<item>idle </item>
|
||||
<item>walk </item>
|
||||
<item>run </item>
|
||||
<item>melee </item>
|
||||
<item>death </item>
|
||||
<item>build </item>
|
||||
<item>gather_fruit </item>
|
||||
<item>gather_grain </item>
|
||||
<item>gather_meat </item>
|
||||
<item>gather_tree </item>
|
||||
<item>gather_rock </item>
|
||||
<item>gather_ore </item>
|
||||
<item>gather_ruins </item>
|
||||
<item>gather_treasure</item>
|
||||
<item>idle </item>
|
||||
<item>melee </item>
|
||||
<item>run </item>
|
||||
<item>walk </item>
|
||||
</animations>
|
||||
|
||||
<playercolours>
|
||||
@ -56,14 +53,4 @@
|
||||
<colour name="Player 8" rgb="64 64 64" buttontext="255 255 255"/>
|
||||
</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>
|
||||
|
BIN
binaries/data/tools/atlas/toolbar/player.png
(Stored with Git LFS)
Normal file
BIN
binaries/data/tools/atlas/toolbar/player.png
(Stored with Git LFS)
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user