2008-01-19 10:57:25 +00:00
|
|
|
#include <engine/e_common_interface.h>
|
2008-08-17 08:52:24 +00:00
|
|
|
#include "layers.hpp"
|
2008-01-13 11:15:32 +00:00
|
|
|
|
2008-01-29 21:39:41 +00:00
|
|
|
static MAPITEM_LAYER_TILEMAP *game_layer = 0;
|
|
|
|
static MAPITEM_GROUP *game_group = 0;
|
2008-01-13 11:15:32 +00:00
|
|
|
|
|
|
|
static int groups_start = 0;
|
|
|
|
static int groups_num = 0;
|
|
|
|
static int layers_start = 0;
|
|
|
|
static int layers_num = 0;
|
|
|
|
|
|
|
|
void layers_init()
|
|
|
|
{
|
|
|
|
map_get_type(MAPITEMTYPE_GROUP, &groups_start, &groups_num);
|
2008-03-29 11:44:03 +00:00
|
|
|
map_get_type(MAPITEMTYPE_LAYER, &layers_start, &layers_num);
|
2008-01-13 11:15:32 +00:00
|
|
|
|
2008-03-29 11:44:03 +00:00
|
|
|
for(int g = 0; g < layers_num_groups(); g++)
|
2008-01-13 11:15:32 +00:00
|
|
|
{
|
2008-03-29 11:44:03 +00:00
|
|
|
MAPITEM_GROUP *group = layers_get_group(g);
|
|
|
|
for(int l = 0; l < group->num_layers; l++)
|
2008-01-13 11:15:32 +00:00
|
|
|
{
|
2008-03-29 11:44:03 +00:00
|
|
|
MAPITEM_LAYER *layer = layers_get_layer(group->start_layer+l);
|
|
|
|
|
2008-01-13 11:15:32 +00:00
|
|
|
if(layer->type == LAYERTYPE_TILES)
|
|
|
|
{
|
|
|
|
MAPITEM_LAYER_TILEMAP *tilemap = (MAPITEM_LAYER_TILEMAP *)layer;
|
|
|
|
if(tilemap->flags&1)
|
2008-01-29 21:39:41 +00:00
|
|
|
{
|
2008-01-13 11:15:32 +00:00
|
|
|
game_layer = tilemap;
|
2008-03-29 11:44:03 +00:00
|
|
|
game_group = group;
|
2008-01-29 21:39:41 +00:00
|
|
|
}
|
2008-03-29 11:44:03 +00:00
|
|
|
}
|
2008-01-13 11:15:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int layers_num_groups() { return groups_num; }
|
|
|
|
MAPITEM_GROUP *layers_get_group(int index)
|
|
|
|
{
|
|
|
|
return (MAPITEM_GROUP *)map_get_item(groups_start+index, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
MAPITEM_LAYER *layers_get_layer(int index)
|
|
|
|
{
|
|
|
|
return (MAPITEM_LAYER *)map_get_item(layers_start+index, 0, 0);
|
|
|
|
}
|
|
|
|
|
2008-01-29 21:39:41 +00:00
|
|
|
MAPITEM_LAYER_TILEMAP *layers_game_layer()
|
2008-01-13 11:15:32 +00:00
|
|
|
{
|
|
|
|
return game_layer;
|
|
|
|
}
|
|
|
|
|
2008-01-29 21:39:41 +00:00
|
|
|
MAPITEM_GROUP *layers_game_group()
|
|
|
|
{
|
|
|
|
return game_group;
|
|
|
|
}
|
|
|
|
|