4 // Copyright (C) 2006 Matthias Braun <matze@braunis.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.
24 #include "floating_image.hpp"
26 #include "object/floating_image.hpp"
27 #include "worldmap/worldmap.hpp"
32 FloatingImage::FloatingImage(const std::string& spritefile)
34 using namespace WorldMapNS;
36 floating_image = new _FloatingImage(spritefile);
37 if(Sector::current() != NULL) {
38 Sector::current()->add_object(floating_image);
39 } else if(WorldMap::current() != NULL) {
40 WorldMap::current()->add_object(floating_image);
42 delete floating_image;
43 throw new std::runtime_error("Neither sector nor worldmap active");
47 FloatingImage::~FloatingImage()
49 floating_image->remove_me();
50 // no delete here, Sector will do that
54 FloatingImage::set_layer(int layer)
56 floating_image->set_layer(layer);
60 FloatingImage::get_layer()
62 return floating_image->get_layer();
66 FloatingImage::set_pos(float x, float y)
68 floating_image->set_pos(Vector(x, y));
72 FloatingImage::get_pos_x()
74 return floating_image->get_pos().x;
78 FloatingImage::get_pos_y()
80 return floating_image->get_pos().y;
84 FloatingImage::set_anchor_point(int anchor)
86 floating_image->set_anchor_point((AnchorPoint) anchor);
90 FloatingImage::get_anchor_point()
92 return (int) floating_image->get_anchor_point();
96 FloatingImage::get_visible()
98 return floating_image->get_visible();
102 FloatingImage::set_visible(bool visible)
104 floating_image->set_visible(visible);
108 FloatingImage::set_action(const std::string& action)
110 floating_image->set_action(action);
114 FloatingImage::get_action()
116 return floating_image->get_action();