-#include "lispreader.h"
-#include "vector.h"
-#include "screen/drawing_context.h"
-
-/** Dirty little helper to create a surface from a snipped of lisp:
- *
- * "filename"
- * (region "filename" x y w h)
- */
-static
-Surface* create_surface(lisp_object_t* cur)
-{
- if (lisp_string_p(cur))
- {
- return new Surface(datadir + "/images/tilesets/" + lisp_string(cur),
- USE_ALPHA);
- }
- else if (lisp_cons_p(cur) && lisp_symbol_p(lisp_car(cur)))
- {
- lisp_object_t* sym = lisp_car(cur);
- lisp_object_t* data = lisp_cdr(cur);
-
- if (strcmp(lisp_symbol(sym), "region") == 0)
- {
- if (lisp_list_length(data) == 5) // (image-region filename x y w h)
- {
- return new Surface(datadir + "/images/tilesets/" + lisp_string(lisp_car(data)),
- lisp_integer(lisp_list_nth(data, 1)),
- lisp_integer(lisp_list_nth(data, 2)),
- lisp_integer(lisp_list_nth(data, 3)),
- lisp_integer(lisp_list_nth(data, 4)),
- USE_ALPHA);
- }
- else
- {
- std::cout << "Tile: Type mispatch, should be '(region \"somestring\" x y w h)'" << std::endl;
- return 0;
- }
- }
- else
- {
- std::cout << "Tile: Unhandled tag: " << lisp_symbol(sym) << std::endl;
- return 0;
- }
- }
-
- std::cout << "Tile: unhandled element" << std::endl;
- return 0;
-}
-
-/** Create a vector of surfaces (aka Sprite) from a piece of lisp:
- ((image "bla.png") (image-region "bla.png") ...)
- */
-static
-std::vector<Surface*> create_surfaces(lisp_object_t* cur)
-{
- std::vector<Surface*> surfs;
-
- while(cur)
- {
- Surface* surface = create_surface(lisp_car(cur));
- if (surface)
- surfs.push_back(surface);
- else
- std::cout << "Tile: Couldn't create image" << std::endl;
-
- cur = lisp_cdr(cur);
- }
-
- return surfs;
-}