/* * Copyright (C) 2013 Patrick "P. J." McDermott * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this program. If not, see * . */ #ifndef RESOURCE_MAP_H #define RESOURCE_MAP_H #include #include "resource.h" #include "palette.h" #include "image.h" enum map_palette_id { MAP_PALETTE_DEFAULT = 0, MAP_PALETTE_MORN, MAP_PALETTE_DAY, MAP_PALETTE_EVE, MAP_PALETTE_NIGHT, MAP_PALETTES_MAX }; enum map_layer { MAP_LAYER_GROUND = 0, MAP_LAYER_OBJ_LOW, MAP_LAYER_OBJ_MID, MAP_LAYER_OBJ_HIGH, MAP_LAYER_COLLISION, MAP_LAYER_WEATHER, MAP_LAYERS_MAX }; struct map_palette { struct palette *palette; Uint16 min; }; struct tileset { struct resource res; char *dirname; char *name; int tilewidth; int tileheight; int width; int height; enum { TILESET_TYPE_IMAGE, TILESET_TYPE_COLLISION } type; struct image *image; Uint8 *collision_tiles; int cur_collision_tile; }; struct map_tileset { struct tileset *tileset; Uint32 firstgid; struct map_tileset *next; }; struct layer { struct map *map; Uint32 *tiles; char *encoding; char *compression; char *raw_data; }; struct map_collision { enum { COLLISION_NONE = 0, COLLISION_CHAR, COLLISION_OBJ, COLLISION_EXIT } type; union { /* struct character *c;*/ Uint8 o; struct map_exit *e; } data; }; struct map_exit { struct map *map; int x; int y; int width; int height; char *target_map_name; struct map *target_map; int target_x_coord; int target_y_coord; struct map_exit *next; }; struct map_spawn { struct map *map; int x; int y; int width; int height; int player; struct map_spawn *next; }; struct map { struct resource res; char *dirname; /* TODO: Consider making these Uint16s. */ int width; int height; int tilewidth; int tileheight; struct map_palette palettes[MAP_PALETTES_MAX]; struct map_tileset *tilesets_head; struct map_tileset *tilesets_tail; struct layer layers[MAP_LAYERS_MAX]; struct map_collision *collisions; struct map_exit *map_exits_head; struct map_exit *map_exits_tail; Uint32 cur_ts_firstgid; }; struct map *map_get(const char *path); void map_free(struct map *map); void map_add_tileset(struct map *m, struct tileset *t, Uint32 firstgid); struct map_palette *map_get_palette(struct map *m, const char *name); struct layer *map_get_layer(struct map *m, const char *name); void map_add_exit(struct map *m, struct map_exit *e); #endif