Public API for loading JSON-formatted Tiled maps and tilesets.
More...
|
| Map * | tmj_map_loadf (const char *path, bool check_extension) |
| | Loads the Tiled map from the file at the given path.
|
| Map * | tmj_map_load (const char *map, const char *name) |
| | Loads the Tiled map from the given JSON object string.
|
| Tileset * | tmj_tileset_loadf (const char *path, bool check_extension) |
| | Loads the Tiled tileset at the given path.
|
| Tileset * | tmj_tileset_load (const char *tileset) |
| | Loads the Tiled tileset from the given JSON object string.
|
| void | tmj_map_free (Map *map) |
| | Frees the memory associated with the given map.
|
| void | tmj_tileset_free (Tileset *tileset) |
| | Frees the memory associated with the given tileset.
|
| void | tmj_log_regcb (bool debug, void(*callback)(tmj_log_priority, const char *)) |
| | Registers a callback function to handle logging events.
|
| uint32_t * | tmj_decode_layer (const char *data, const char *encoding, const char *compression, size_t *size) |
| | Decodes layer data from a Tiled map layer.
|
Public API for loading JSON-formatted Tiled maps and tilesets.
◆ tmj_log_priority
◆ TMJ_LOG_PRIORITY
| Enumerator |
|---|
| TMJ_LOG_DEBUG | |
| TMJ_LOG_INFO | |
| TMJ_LOG_WARNING | |
| TMJ_LOG_ERR | |
| TMJ_LOG_CRIT | |
Definition at line 502 of file tmj.h.
◆ tmj_map_loadf()
| Map * tmj_map_loadf |
( |
const char * | path, |
|
|
bool | check_extension ) |
Loads the Tiled map from the file at the given path.
The map object returned by this function must not be modified by the caller. The caller must check that layer_count is >0 before attempting to dereference the layers array.
- Parameters
-
| path | A relative or absolute filesystem path. |
| check_extension | If true, validates that the file extension equals ".tmj" or ".json". |
- Returns
- On success, returns a pointer to a map. The map is dynamically-allocated, and must be freed by the caller using map_free(). On failure, returns NULL.
Definition at line 1147 of file map.c.
◆ tmj_map_load()
| Map * tmj_map_load |
( |
const char * | map, |
|
|
const char * | name ) |
Loads the Tiled map from the given JSON object string.
The map object returned by this function must not be modified by the caller. The caller must check that layer_count is >0 before attempting to dereference the layers array.
- Parameters
-
| map | A JSON string containing a Tiled map object. |
| name | A name to use to reference this map in log messages. tmj_map_loadf() does not require this argument, because it uses the file path to identify the map in log messages. |
- Returns
- On success, returns a pointer to a map. The map is dynamically-allocated, and must be freed by the caller using map_free(). On failure, returns NULL.
Definition at line 1185 of file map.c.
◆ tmj_tileset_loadf()
| Tileset * tmj_tileset_loadf |
( |
const char * | path, |
|
|
bool | check_extension ) |
Loads the Tiled tileset at the given path.
The tileset object returned by this function must not be modified by the caller.
- Parameters
-
| path | A relative or absolute filesystem path. |
| check_extension | If true, validates that the file extension equals ".tsj" or ".json". |
- Returns
- On success, returns a pointer to a tileset. The tileset is dynamically-allocated, and must be freed by the caller using tileset_free(). On failure, returns NULL.
Definition at line 623 of file tileset.c.
◆ tmj_tileset_load()
| Tileset * tmj_tileset_load |
( |
const char * | tileset | ) |
|
Loads the Tiled tileset from the given JSON object string.
The tileset object returned by this function must not be modified by the caller.
- Parameters
-
| tileset | A JSON string containing a Tiled tileset object. |
- Returns
- On success, returns a pointer to a tileset. The tileset is dynamically-allocated, and must be freed by the caller using tileset_free(). On failure, returns NULL.
Definition at line 682 of file tileset.c.
◆ tmj_map_free()
| void tmj_map_free |
( |
Map * | map | ) |
|
Frees the memory associated with the given map.
If the map was modified by the caller, this function may cause undefined behavior.
- Parameters
-
| map | A map which was returned by a call to map_load(). |
Definition at line 1199 of file map.c.
◆ tmj_tileset_free()
| void tmj_tileset_free |
( |
Tileset * | tileset | ) |
|
Frees the memory associated with the given tileset.
If the tileset was modified by the caller, this function may cause undefined behavior.
- Parameters
-
| tileset | A tileset which was returned by a call to tileset_load(). |
Definition at line 718 of file tileset.c.
◆ tmj_log_regcb()
| void tmj_log_regcb |
( |
bool | debug, |
|
|
void(* | callback )(tmj_log_priority, const char *) ) |
Registers a callback function to handle logging events.
- Parameters
-
| debug | If set to true, the given callback function will receive debug messages and information in addition to the higher-priority messages. |
| callback | A function that takes a TMJ_LOG_PRIORITY and a char* and returns nothing. |
Definition at line 18 of file log.c.
◆ tmj_decode_layer()
| uint32_t * tmj_decode_layer |
( |
const char * | data, |
|
|
const char * | encoding, |
|
|
const char * | compression, |
|
|
size_t * | size ) |
Decodes layer data from a Tiled map layer.
- Parameters
-
| data | The value of the "data_str" field from a Layer. |
| encoding | The value of the "encoding" field from a Layer. |
| compression | The value of the "compression" field from a Layer. |
| [out] | size | The size of the resultant integer array. |
- Returns
- On Success, returns a dynamically-allocated array of global tile IDs. This array must be freed by the caller. See https://doc.mapeditor.org/en/stable/reference/global-tile-ids/ for more information. On failure, returns NULL.
Definition at line 15 of file util.c.
◆ TMJ_VERSION_MAJOR
| const unsigned int TMJ_VERSION_MAJOR |
|
extern |
The library major version.
An unsigned integer representing the major component of the SemVer 2.0 version of this library.
Definition at line 10 of file util.c.
◆ TMJ_VERSION_MINOR
| const unsigned int TMJ_VERSION_MINOR |
|
extern |
The library minor version.
An unsigned integer representing the minor component of the SemVer 2.0 version of this library.
Definition at line 11 of file util.c.
◆ TMJ_VERSION_PATCH
| const unsigned int TMJ_VERSION_PATCH |
|
extern |
The library patch version.
An unsigned integer representing the patch component of the SemVer 2.0 version of this library.
Definition at line 12 of file util.c.
◆ TMJ_VERSION
| const char* const TMJ_VERSION |
|
extern |
The full library version.
A string containing the full SemVer 2.0 version of this library.
Definition at line 13 of file util.c.