- for(std::vector<std::string>::iterator it = tile->
- filenames.begin();
- it != tile->filenames.end();
- ++it)
- {
- texture_type cur_image;
- tile->images.push_back(cur_image);
- texture_load(&tile->images[tile->images.size()-1],
- datadir + "images/tilesets/" + (*it),
- USE_ALPHA);
- }
+void
+Tile::parse_images(lisp_object_t* list)
+{
+ while(!lisp_nil_p(list)) {
+ lisp_object_t* cur = lisp_car(list);
+ if(lisp_string_p(cur)) {
+ imagespecs.push_back(ImageSpec(lisp_string(cur), Rectangle(0, 0, 0, 0)));
+ } 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) {
+ float x = lisp_integer(lisp_list_nth(data, 1));
+ float y = lisp_integer(lisp_list_nth(data, 2));
+ float width = lisp_integer(lisp_list_nth(data, 3));
+ float height = lisp_integer(lisp_list_nth(data, 4));
+ imagespecs.push_back(ImageSpec(lisp_string(lisp_car(data)),
+ Rectangle(x, y, x+width, y+height)));
+ } else {
+ std::cerr << "Tile: Type mismatch, should be '(region \"somestring\" x y w h)'" << std::endl;
+ continue;
+ }
+ } else {
+ std::cerr << "Expected string or list in images tag.\n";
+ continue;
+ }
+
+ list = lisp_cdr(list);
+ }
+}