- std::vector<std::string> images;
- if(!reader.read_string_vector("images", images))
- st_abort("Sprite contains no images: ", name.c_str());
+void
+Sprite::parse_action(LispReader& lispreader)
+{
+ action = new Action;
+
+ init_defaults(action);
+
+ if(!lispreader.read_string("name", action->name))
+ if(!actions.empty())
+ Termination::abort("Error: If there are more than one action, they need names!", "");
+ lispreader.read_int("x-offset", action->x_offset);
+ lispreader.read_int("y-offset", action->y_offset);
+ lispreader.read_int("z-order", action->z_order);
+ lispreader.read_float("fps", action->fps);
+
+ /* TODO: add a top filter entry */
+ std::vector <int> mask_color;
+ lispreader.read_int_vector("apply-mask", mask_color);
+ if(mask_color.size() == 4)
+ {
+ for(std::vector<Surface*>::iterator i = action->surfaces.begin();
+ i < action->surfaces.end(); i++)
+ {
+ (*i)->apply_mask(Color(mask_color));
+ }
+ }
+
+ action->mirror = false;
+ std::string mirror_action;
+ lispreader.read_string("mirror-action", mirror_action);
+ if(!mirror_action.empty())
+ {
+ action->mirror = true;
+ Action* act_tmp = get_action(mirror_action);
+ if(act_tmp == NULL)
+ std::cerr << "Warning: Could not mirror action. Action not found\n"
+ "Mirror actions must be defined after the real one!\n";
+ else
+ action->surfaces = act_tmp->surfaces;
+ }