diff options
author | P. J. McDermott <pjm@nac.net> | 2013-03-03 01:03:15 (EST) |
---|---|---|
committer | P. J. McDermott <pjm@nac.net> | 2013-03-03 01:03:15 (EST) |
commit | 2e123804750fba47aa88ba3f80c5b0968053437c (patch) | |
tree | 3faf78248b0602b8d01cf8bfd61930fe9106fa6b /src/resources | |
parent | 665e85b511496e0b1c6cbef5c65d4f5df2ba80ef (diff) | |
download | overworld-rpg-2e123804750fba47aa88ba3f80c5b0968053437c.zip overworld-rpg-2e123804750fba47aa88ba3f80c5b0968053437c.tar.gz overworld-rpg-2e123804750fba47aa88ba3f80c5b0968053437c.tar.bz2 |
Add a default map palette.
Diffstat (limited to 'src/resources')
-rw-r--r-- | src/resources/map.c | 19 | ||||
-rw-r--r-- | src/resources/map.h | 3 |
2 files changed, 19 insertions, 3 deletions
diff --git a/src/resources/map.c b/src/resources/map.c index 667781d..0d65d57 100644 --- a/src/resources/map.c +++ b/src/resources/map.c @@ -146,7 +146,9 @@ map_add_tileset(struct map *m, struct tileset *t, Uint32 firstgid) struct map_palette * map_get_palette(struct map *m, const char *name) { - if (strcmp(name, "morn") == 0) { + if (strcmp(name, "default") == 0) { + return &m->palettes[MAP_PALETTE_DEFAULT]; + } else if (strcmp(name, "morn") == 0) { return &m->palettes[MAP_PALETTE_MORN]; } else if (strcmp(name, "day") == 0) { return &m->palettes[MAP_PALETTE_DAY]; @@ -416,7 +418,20 @@ tmx_map_property_start(void *pv, const char *name, const char **attr) if (xml_check_tag(name, "property")) { xml_get_string_attr(p, attr, "name", &attr_name, 1); xml_get_string_attr(p, attr, "value", &attr_value, 1); - if (strncmp(attr_name, "palette-", 7) == 0) { + if (strcmp(attr_name, "palette-default") == 0) { + pal = map_get_palette(m, "default"); + path = malloc(strlen(m->dirname) + + strlen(attr_value) + 2); + if (path == NULL) { + /* XXX: This won't run xml_node_push() and the + * stack will be corrupted. */ + return; + } + sprintf(path, "%s/%s", m->dirname, attr_value); + pal->palette = palette_get(path); + pal->min = 0; + free(path); + } else if (strncmp(attr_name, "palette-", 7) == 0) { pal = map_get_palette(m, attr_name + 8); if (pal != NULL) { /* Uint32 is overkill for pal_h and pal_m, but diff --git a/src/resources/map.h b/src/resources/map.h index 116300d..bac0cd5 100644 --- a/src/resources/map.h +++ b/src/resources/map.h @@ -7,7 +7,8 @@ #include "image.h" enum map_palette_id { - MAP_PALETTE_MORN = 0, + MAP_PALETTE_DEFAULT = 0, + MAP_PALETTE_MORN, MAP_PALETTE_DAY, MAP_PALETTE_EVE, MAP_PALETTE_NIGHT, |