diff options
author | Adam Borowski <kilobyte@angband.pl> | 2011-12-14 20:14:32 +0100 |
---|---|---|
committer | Adam Borowski <kilobyte@angband.pl> | 2011-12-14 22:10:06 +0100 |
commit | 74e48517d3c44a7684c38d71b64d1f1397f59d48 (patch) | |
tree | 6413bbd08162291ba5e04447cf5f5000ed939793 /crawl-ref/source/rltiles/tool | |
parent | e7bee85ce1ee7aa248652ca0edae84e4fe2243c4 (diff) | |
download | crawl-ref-74e48517d3c44a7684c38d71b64d1f1397f59d48.tar.gz crawl-ref-74e48517d3c44a7684c38d71b64d1f1397f59d48.zip |
Allow running the rltile tool with no #define USE_TILE.
In this case, it will produce enums but no images, avoiding a dependency on
SDL. Since production of images is very deeply intertwined with rest of
processing, this change is a nasty hack all around, having it process 0x0
dummy images all over. Doesn't seem to explode, though.
Diffstat (limited to 'crawl-ref/source/rltiles/tool')
-rw-r--r-- | crawl-ref/source/rltiles/tool/main.cc | 4 | ||||
-rw-r--r-- | crawl-ref/source/rltiles/tool/tile.cc | 27 | ||||
-rw-r--r-- | crawl-ref/source/rltiles/tool/tile_colour.cc | 6 | ||||
-rw-r--r-- | crawl-ref/source/rltiles/tool/tile_page.cc | 4 |
4 files changed, 35 insertions, 6 deletions
diff --git a/crawl-ref/source/rltiles/tool/main.cc b/crawl-ref/source/rltiles/tool/main.cc index cf3966d30d..17f22dd9b4 100644 --- a/crawl-ref/source/rltiles/tool/main.cc +++ b/crawl-ref/source/rltiles/tool/main.cc @@ -1,7 +1,9 @@ #include <stdio.h> #include "tile_list_processor.h" -#include <SDL_main.h> +#ifdef USE_TILE + #include <SDL_main.h> +#endif int main(int argc, char **argv) { diff --git a/crawl-ref/source/rltiles/tool/tile.cc b/crawl-ref/source/rltiles/tool/tile.cc index 923a1f497f..645d44d5cc 100644 --- a/crawl-ref/source/rltiles/tool/tile.cc +++ b/crawl-ref/source/rltiles/tool/tile.cc @@ -4,8 +4,10 @@ #include <memory.h> #include <assert.h> -#include <SDL.h> -#include <SDL_image.h> +#ifdef USE_TILE + #include <SDL.h> + #include <SDL_image.h> +#endif tile::tile() : m_width(0), m_height(0), m_pixels(NULL), m_shrink(true) { @@ -39,7 +41,11 @@ void tile::unload() bool tile::valid() const { +#ifdef USE_TILE return m_pixels && m_width && m_height; +#else + return m_pixels && !m_width && !m_height; +#endif } const std::string &tile::filename() const @@ -293,6 +299,7 @@ void tile::copy(const tile &img) bool tile::compose(const tile &img) { +#ifdef USE_TILE if (!valid()) { fprintf(stderr, "Error: can't compose onto an unloaded image.\n"); @@ -323,6 +330,7 @@ bool tile::compose(const tile &img) dest->b = (src->b * src->a + dest->b * (255 - src->a)) / 255; dest->a = (src->a * 255 + dest->a * (255 - src->a)) / 255; } +#endif return (true); } @@ -369,6 +377,7 @@ bool tile::load(const std::string &new_filename) if (m_pixels) unload(); +#ifdef USE_TILE SDL_Surface *img = IMG_Load(new_filename.c_str()); if (!img) return (false); @@ -450,6 +459,11 @@ bool tile::load(const std::string &new_filename) SDL_FreeSurface(img); replace_colour(tile_colour::background, tile_colour::transparent); +#else + m_width = 0; + m_height = 0; + m_pixels = new tile_colour[0]; +#endif return (true); } @@ -474,8 +488,13 @@ void tile::replace_colour(tile_colour &find, tile_colour &replace) tile_colour &tile::get_pixel(unsigned int x, unsigned int y) { +#ifdef USE_TILE assert(m_pixels && x < m_width && y < m_height); return m_pixels[x + y * m_width]; +#else + static tile_colour dummy; + return dummy; +#endif } void tile::get_bounding_box(int &x0, int &y0, int &w, int &h) @@ -487,8 +506,8 @@ void tile::get_bounding_box(int &x0, int &y0, int &w, int &h) } x0 = y0 = 0; - unsigned int x1 = m_width - 1; - unsigned int y1 = m_height - 1; + int x1 = m_width - 1; + int y1 = m_height - 1; while (x0 <= x1) { bool found = false; diff --git a/crawl-ref/source/rltiles/tool/tile_colour.cc b/crawl-ref/source/rltiles/tool/tile_colour.cc index 3c6ac3765c..8058624e2a 100644 --- a/crawl-ref/source/rltiles/tool/tile_colour.cc +++ b/crawl-ref/source/rltiles/tool/tile_colour.cc @@ -3,7 +3,9 @@ #include <vector> #include <stdlib.h> #include <stdio.h> -#include <png.h> +#ifdef USE_TILE + #include <png.h> +#endif tile_colour tile_colour::background(71, 108, 108, 255); tile_colour tile_colour::transparent(0, 0, 0, 0); @@ -249,6 +251,7 @@ void tile_colour::change_lum(int lum_percent) set_from_hsl(hue, sat, lum); } +#ifdef USE_TILE bool write_png(const char *filename, tile_colour *pixels, unsigned int width, unsigned int height) { @@ -298,3 +301,4 @@ bool write_png(const char *filename, tile_colour *pixels, return (true); } +#endif diff --git a/crawl-ref/source/rltiles/tool/tile_page.cc b/crawl-ref/source/rltiles/tool/tile_page.cc index eeb1828b5c..810dffbc21 100644 --- a/crawl-ref/source/rltiles/tool/tile_page.cc +++ b/crawl-ref/source/rltiles/tool/tile_page.cc @@ -127,6 +127,7 @@ bool tile_page::add_synonym(const std::string &enumname, const std::string &syn) bool tile_page::write_image(const char *filename) { +#ifdef USE_TILE if (m_width * m_height <= 0) { fprintf(stderr, "Error: failed to write image. No images placed?\n"); @@ -159,6 +160,9 @@ bool tile_page::write_image(const char *filename) bool success = write_png(filename, pixels, m_width, m_height); delete[] pixels; return success; +#else + return true; +#endif } void tile_page::add_variation(int var_idx, int base_idx, int colour) |