4 // Copyright (C) 2008 Christoph Sommer <christoph.sommer@2008.expires.deltadevelopment.de>
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 #include "video/drawing_context.hpp"
26 #include "lisp/lisp.hpp"
27 #include "lisp/writer.hpp"
28 #include "object_factory.hpp"
29 #include "resources.hpp"
33 Decal::Decal(const lisp::Lisp& reader)
34 : layer(LAYER_OBJECTS)
42 if(!reader.get("image", imagefile)) throw std::runtime_error("Must specify image for decal");
43 image.reset(new Surface(imagefile));
45 reader.get("layer", layer);
53 Decal::write(lisp::Writer& writer)
55 writer.start_list("decal");
56 writer.write_float("x", pos.x);
57 writer.write_float("y", pos.y);
58 writer.write_string("image", imagefile);
59 writer.write_int("layer", layer);
60 writer.end_list("decal");
69 Decal::draw(DrawingContext& context)
71 if(!image.get()) return;
72 context.draw_surface(image.get(), pos, layer);
75 IMPLEMENT_FACTORY(Decal, "decal");